Plugin Directory

Changeset 2829334


Ignore:
Timestamp:
12/06/2022 12:27:35 PM (3 years ago)
Author:
minicrmio
Message:

Support for order custom fields

Location:
minicrm-woocommerce-sync/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • minicrm-woocommerce-sync/trunk/languages/minicrm-woocommerce-sync.pot

    r2790857 r2829334  
    44"Project-Id-Version: MiniCRM "
    55"WooCommerce Sync plugin "
    6 "v1.5.20\n"
     6"v1.5.22\n"
    77"POT-Creation-Date: 2022-05-30 "
    88"22:22+0200\n"
  • minicrm-woocommerce-sync/trunk/lib/Integration.php

    r2736790 r2829334  
    436436        // Check WooCommerce order properties
    437437        $invalid = array_filter (array_keys ($mapping), function ($wcProp) {
    438             return !method_exists (\WC_Order::class, "get_$wcProp");
     438            $wco_Class = apply_filters( 'woocommerce_order_class', \WC_Order::class, 'order', 0 );
     439            return !method_exists ($wco_Class, "get_$wcProp");
    439440        });
    440441        if (count ($invalid)) {
  • minicrm-woocommerce-sync/trunk/lib/Plugin.php

    r2582919 r2829334  
    150150        }
    151151        return $project_id;
     152    }
     153
     154    /**
     155     * This function validates the fields mappings (WooCommerce data mapping)
     156     * @return void
     157     */
     158    public static function validate_configured_fields ()
     159    {
     160        $textValue = Integration::getOption ('wc_mapping');
     161        $mapping = Integration::getMapping ($textValue);
     162        $missingFields=array();
     163
     164        $wco_Class = apply_filters( 'woocommerce_order_class', \WC_Order::class, 'order', 0 );
     165
     166        foreach ($mapping as $wcField => $mcField) {
     167            $method = "get_$wcField";
     168            do_action( 'qm/debug',  $method);
     169
     170            if( !method_exists ($wco_Class, $method) ) {
     171                array_push($missingFields, "$wcField:$mcField");
     172            }
     173        }
     174
     175        if( count($missingFields) > 0) {
     176            do_action( 'ppppp-debug-notice' );
     177            add_action(
     178                'admin_notices',
     179                self::_ignoreTypeErrors (function () use(&$missingFields){
     180                    print('<div class="error notice"><p>'.
     181                        sprintf(__('<h3><strong>Error: MiniCRM Woocommerce Sync</strong></h3><strong>Sync will fail!</strong><br>Missing configured fields:<br>%s', 'minicrm-woocommerce-sync'),
     182                        join('<br>', $missingFields)
     183                    ).
     184                    '</p></div>');
     185                })
     186            );
     187        }
    152188    }
    153189
  • minicrm-woocommerce-sync/trunk/minicrm-woocommerce-sync.php

    r2790857 r2829334  
    1010 * Requires PHP: 7.2.0
    1111 * Text Domain: minicrm-woocommerce-sync
    12  * Version: 1.5.20
     12 * Version: 1.5.22
    1313 * WC requires at least: 4.0.0
    1414 * WC tested up to: 6.6
     
    7979    0
    8080);
     81
     82// Validate field mappings and display error message if missing fields found
     83add_action (
     84    'admin_init',
     85    function () {
     86        Plugin::validate_configured_fields ();
     87    },
     88    10,
     89    0
     90);
  • minicrm-woocommerce-sync/trunk/readme.txt

    r2790857 r2829334  
    55Requires at least: 4.9
    66Requires PHP: 7.2.0
    7 Stable tag: 1.5.20
     7Stable tag: 1.5.22
    88Tested up to: 6.0
    99WC requires at least: 4.0.0
Note: See TracChangeset for help on using the changeset viewer.