Plugin Directory

Changeset 2839827


Ignore:
Timestamp:
12/27/2022 01:11:49 PM (3 years ago)
Author:
extendago
Message:

Version 1.2.6

Location:
extendago-wp-connection/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extendago-wp-connection/trunk/extendago-wp-connection.php

    r2826526 r2839827  
    44Plugin URI:  http://www.arture.nl/extendago
    55Description: The Wordpress plugin for connecting Woocommerce with Extendago / Wallmob. Manage your products inside Extendago and let our connection do the magic.
    6 Version:     1.2.5
     6Version:     1.2.6
    77Author:      Arture B.V.
    88Author URI:  https://arture.nl/
  • extendago-wp-connection/trunk/includes/api/class-arture-web-api.php

    r2722441 r2839827  
    7474            $current_screen = get_current_screen();
    7575            if (!isset($current_screen) || $current_screen->base == 'toplevel_page_extendago-wp-connection-panel') {
    76                 $request_url = '/validate/' . $api_key . '/' . str_replace(array('http://', 'https://', 'www.'), '', get_bloginfo('wpurl'));
     76                $site_url = get_bloginfo('wpurl');
     77                $site_url = str_replace(array('http://', 'https://', 'www.'), '', $site_url);
     78                $site_url = str_replace('/', '_', $site_url);
     79                $request_url = '/validate/' . $api_key . '/' . $site_url;
    7780                $results = $this->curl_request($request_url);
    7881
  • extendago-wp-connection/trunk/includes/cronjob/class-extendago-cronjob-functions.php

    r2826526 r2839827  
    7171    }
    7272
    73     public function extendago_woocommerce_sync(){
     73    public function extendago_woocommerce_sync( $product_id = '' ){
    7474
    7575        $extendago_masterdata = array();
     
    108108        if( !isset($_POST['product_id']) ) $this->logging->log_file_write( 'GetAllWebshopProducts | ' .count($products) );
    109109
     110        if( isset($_POST['sc_product_id']) && !empty($_POST['sc_product_id']) ) {
     111            $this->logging->log_file_write( 'Manual | Manual triggered synchronisation for product: ' .$_POST['sc_product_id']);
     112        }
     113
    110114        // Process all products
    111115        if( isset($products) && !empty($products) ) {
     
    120124            $total_sychronized_products = 0;
    121125            $total_products = count($products);
    122             if( isset($_POST['product_id']) ) $total_products = 1;
     126            if( ( isset($_POST['product_id']) && !empty($_POST['product_id']) ) || ( isset($product_id) && !empty($product_id) ) ) $total_products = 1;
    123127            $products_array = array();
    124128            foreach( $products as $product ) {
    125129
    126130                if( isset($_POST['product_id']) && !empty($_POST['product_id']) && $product['id'] != $_POST['product_id'] ){
     131                    continue;
     132                }
     133
     134                if( isset($product_id) && !empty($product_id) && $product['id'] != $product_id ){
    127135                    continue;
    128136                }
     
    206214        $this->logging->log_file_write( 'MasterData | SAVED' );
    207215
    208         wp_send_json_success(
    209             array(
    210                 'html' => '<div class="notice notice-success"><p>'. __( 'Manual triggered the init synchronization', 'extendago-wp-connection-plugin' ). '</p></div>'
    211             )
    212         );
     216        if( !isset($product_id) || empty($product_id) ){
     217            wp_send_json_success(
     218                array(
     219                    'html' => '<div class="notice notice-success"><p>'. __( 'Manual triggered the init synchronization', 'extendago-wp-connection-plugin' ). '</p></div>'
     220                )
     221            );
     222        }
     223
    213224    }
    214225
     
    291302                        foreach( $product_data['attributes'] as $attribute => $attribute_value ){
    292303                            if( isset($variation_meta['attribute_'.$attribute]) ){
    293                                 $product_variant_name = $variation_meta['attribute_'.$attribute][0];
     304                                $Variation = new WC_Product_Variation( $product_variation_id );
     305                                $attribute_name = $Variation->get_name();
     306                                $attribute_name = explode(" - ", $attribute_name);
     307                                $product_variant_name = end($attribute_name);
    294308                                break;
    295309                            }
     
    632646                        }
    633647
     648                        $unit_id = get_post_meta($product['id'], 'unit_id', true);
     649                        if( !isset($unit_id) || empty($unit_id) ){
     650                            $unit_id = 'pc';
     651                        }
     652
     653                        $ExtendagoProductJSON['product_data'] = json_encode(array(
     654                            array(
     655                                'id'                    => $product['id'],
     656                                'type_id'               => '523',
     657                                'retail_price'          => number_format(((float)$product['price'] * 100), 0, '.', ''), // price in cents
     658                                //'cost_price'            => '0',
     659                                'product_id'            => $product['id'],
     660                                'price_region_id'       => $price_region_id,
     661                                'vat_rate_id'           => null,
     662                                'least_quantity'        => null,
     663                                'weekcover'             => 0,
     664                                'sales_tax_rate_id'     => null,
     665                                'unit_id'               => $unit_id
     666                            )
     667                        ));
     668
    634669                        if( isset($product['variations']) && !empty($product['variations']) ) {
    635670
     
    654689                                            'type_id'               => '523',
    655690                                            'retail_price'          => number_format(((float)$variation->retail_price * 100), 0, '.', ''), // price in cents
    656                                             'cost_price'            => '0',
     691                                            //'cost_price'            => '0',
    657692                                            'product_id'            => $product['id'],
    658693                                            'price_region_id'       => $price_region_id,
     
    675710                                            'type_id'               => '523',
    676711                                            'retail_price'          => number_format(((float)$variation->retail_price * 100), 0, '.', ''), // price in cents
    677                                             'cost_price'            => '0',
     712                                            //'cost_price'            => '0',
    678713                                            'product_id'            => $product['id'],
    679714                                            'product_variant_id'    => $variation->id,
     
    692727
    693728                            $ExtendagoProductJSON['product_variants'] = json_encode($ExtendagoProductJSON['product_variants']);
    694                         }
    695                         else{
    696 
    697                             $unit_id = get_post_meta($product['id'], 'unit_id', true);
    698                             if( !isset($unit_id) || empty($unit_id) ){
    699                                 $unit_id = 'pc';
    700                             }
    701 
    702                             $ExtendagoProductJSON['product_data'] = json_encode(array(
    703                                 array(
    704                                     'id'                    => $product['id'],
    705                                     'type_id'               => '523',
    706                                     'retail_price'          => number_format(((float)$product['price'] * 100), 0, '.', ''), // price in cents
    707                                     'cost_price'            => '0',
    708                                     'product_id'            => $product['id'],
    709                                     'price_region_id'       => $price_region_id,
    710                                     'vat_rate_id'           => null,
    711                                     'least_quantity'        => null,
    712                                     'weekcover'             => 0,
    713                                     'sales_tax_rate_id'     => null,
    714                                     'unit_id'               => $unit_id
    715                                 )
    716                             ));
    717729                        }
    718730
     
    892904
    893905        if( isset($changes) && $changes['changes_found'] > 0 ) {
     906
     907            $this->logging->log_file_write('Changes | Extendago product changes amount: ' . $changes['changes_found']);
    894908
    895909            $sync_round_identifier = time();
  • extendago-wp-connection/trunk/includes/woocommerce/class-extendago-woocommerce-functions.php

    r2826334 r2839827  
    176176                    }
    177177
     178                    $variation_meta = get_post_meta($product_variation_id);
     179                    foreach( $product_data['attributes'] as $attribute => $attribute_value ){
     180                        if( isset($variation_meta['attribute_'.$attribute]) ){
     181                            $Variation = new WC_Product_Variation( $product_variation_id );
     182                            $attribute_name = $Variation->get_name();
     183                            $attribute_name = explode(" - ", $attribute_name);
     184                            $product_variant_name = end($attribute_name);
     185                            break;
     186                        }
     187                    }
     188
    178189                    if( isset($product_variant_name) ) {
    179190                        $product_data['variations'][] = array(
     
    558569                }
    559570
    560                 echo '<pre>';
    561                 print_r($order->get_items( 'shipping' ) );
    562                 echo '</pre>';
     571                if (!empty($order_data['shipping']['email'])) {
     572                    $data['shipping_information']['email'] = $order_data['shipping']['email'];
     573                } else {
     574                    $data['shipping_information']['email'] = $order_data['billing']['email'];
     575                }
     576
     577                if (!empty($order_data['shipping']['phone'])) {
     578                    $data['shipping_information']['phone'] = $order_data['shipping']['phone'];
     579                } else {
     580                    $data['shipping_information']['phone'] = $order_data['billing']['phone'];
     581                }
    563582
    564583                // Iterating through order shipping items
  • extendago-wp-connection/trunk/readme.txt

    r2826526 r2839827  
    55Requires at least: 6.0
    66Tested up to: 6.1.1
    7 Stable tag: 1.2.5
     7Stable tag: 1.2.6
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    3030
    3131== Changelog ==
     32
     33= 1.2.6 =
     34* Better performance of export products with variation names
     35* Bugfix with cost_price and export processing
     36* Added phone and email to order shipping fields
    3237
    3338= 1.2.5 =
Note: See TracChangeset for help on using the changeset viewer.