Plugin Directory

Changeset 2941124


Ignore:
Timestamp:
07/21/2023 06:30:59 AM (3 years ago)
Author:
extendago
Message:

Version 1.4.0

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

Legend:

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

    r2940233 r2941124  
    44Plugin URI:  http://www.arture.nl/extendago
    55Description: The Wordpress plugin for connecting Woocommerce with Extenda GO / Wallmob. You can manage your products inside Extenda GO or make your webshop as leading foor product manangement. You Stock changes will be two-way binding.
    6 Version:     1.3.9
     6Version:     1.4.0
    77Author:      Arture B.V.
    88Author URI:  https://arture.nl/
  • extendago-wp-connection/trunk/includes/class-extendago-wp-connection.php

    r2940233 r2941124  
    6868        $this->loader->add_action( 'wp_ajax_check_extendago_voucher', $woocommerce, 'check_extendago_voucher' );
    6969        $this->loader->add_action( 'wp_ajax_nopriv_check_extendago_voucher', $woocommerce, 'check_extendago_voucher' );
    70         //$this->loader->add_action( 'woocommerce_order_status_changed', $woocommerce, 'create_extendago_new_order' );
     70        $this->loader->add_action( 'woocommerce_order_status_changed', $woocommerce, 'create_extendago_new_order' );
    7171        $this->loader->add_action( 'manage_edit-shop_order_columns', $woocommerce, 'add_extendago_order_returned_column' );
    7272        $this->loader->add_action( 'manage_shop_order_posts_custom_column', $woocommerce, 'add_extendago_order_returned_column_value' );
  • extendago-wp-connection/trunk/includes/cronjob/class-extendago-cronjob-functions.php

    r2930779 r2941124  
    109109
    110110        if( isset($_POST['product_id']) && !empty($_POST['product_id']) ) {
     111            $product_id = $_POST['product_id'];
    111112            $this->logging->log_file_write( 'Manual | Manual triggered synchronisation for product: ' .$_POST['product_id']);
    112113        }
     
    114115        $import_shop_products = get_option( 'extendago_import_shop_products' );
    115116        $extendago_shop_group_ids = get_option( 'extendago_shop_group_ids' );
     117
    116118
    117119        // Process all products
     
    127129            $total_sychronized_products = 0;
    128130            $total_products = count($products);
    129             if( ( isset($_POST['product_id']) && !empty($_POST['product_id']) ) || ( isset($product_id) && !empty($product_id) ) ) $total_products = 1;
     131            if( isset($product_id) && !empty($product_id) ) $total_products = 1;
    130132            $products_array = array();
    131133            foreach( $products as $product ) {
    132134                $skip_product = false;
    133135
    134                 if( isset($_POST['product_id']) && !empty($_POST['product_id']) && $product['id'] != $_POST['product_id'] ){
    135                     $total_products--;
    136                     $skip_product = true;
    137                 }
    138 
    139136                if( isset($product_id) && !empty($product_id) && $product['id'] != $product_id ){
    140                     $total_products--;
    141                     $skip_product = true;
     137                    continue;
    142138                }
    143139
    144140                // Skip producten met de optie "Hide form web"
    145141                if( isset($product['attributes'][1]['hide_from_web']) && $product['attributes'][1]['hide_from_web'] == '1' ){
    146                     $total_products--;
     142                    $total_products = $total_products - 1;
    147143                    $skip_product = true;
    148144                }
     
    154150                    }
    155151                    else{
    156                         $total_products--;
     152                        $total_products = $total_products - 1;
    157153                        $skip_product = true;
    158154                    }
     
    162158                if( !$skip_product ) {
    163159                    $stock_values = $web_api->CurlRequest('/stock_values?filter-product_id=' . $product['id'], 'GET');
    164                     if (isset($extendago_location_id) && !empty($extendago_location_id)) {
    165                         foreach ($stock_values as $stock_value) {
    166                             if ($stock_value['stock_location_id'] == $extendago_location_id) {
    167                                 $product['stock'] = floor($stock_value['quantity']);
    168                                 break;
    169                             }
    170                         }
    171                     } else {
    172                         $product['stock'] = floor($stock_values[0]['quantity']);
     160                    if( isset($stock_values) && !empty($stock_values) ) {
     161                        if (isset($extendago_location_id) && !empty($extendago_location_id)) {
     162                            foreach ($stock_values as $stock_value) {
     163                                if ($stock_value['stock_location_id'] == $extendago_location_id) {
     164                                    $product['stock'] = floor($stock_value['quantity']);
     165                                    break;
     166                                }
     167                            }
     168                        } else {
     169                            $product['stock'] = floor($stock_values[0]['quantity']);
     170                        }
     171                    }
     172                    else{
     173                        $product['stock'] = 0;
    173174                    }
    174175
     
    934935                                $stock_value['reference_id'] = 'UpdateStock - webshop';
    935936                                $stock_value['stock_event_lines'] = json_encode( array( array(
    936                                         'current_quantity'      => $variation->stock,
    937                                         'product_id'            => $product['id'],
    938                                         'product_variant_id'    => $product_variant['id'],
    939                                         'name'                  => $product_variant['title'],
    940                                         'sku'                   => $product_variant['sku'],
    941                                     )
     937                                    'current_quantity'      => $variation->stock,
     938                                    'product_id'            => $product['id'],
     939                                    'product_variant_id'    => $product_variant['id'],
     940                                    'name'                  => $product_variant['title'],
     941                                    'sku'                   => $product_variant['sku'],
     942                                )
    942943                                ));
    943944
     
    958959                                    }
    959960                                }
    960                              }
    961                        }
     961                            }
     962                        }
    962963                        else{
    963964                            $Response = $Extendago->CurlRequest('/stock_values?filter-product_id='.$product['id'], 'GET');
     
    965966                            $stock_value['reference_id'] = 'UpdateStock - webshop';
    966967                            $stock_value['stock_event_lines'] = json_encode( array( array(
    967                                     'current_quantity'      => (string)$product['quantity'],
    968                                     'product_id'            => (string)$product['id'],
    969                                     'product_variant_id'    => null,
    970                                     'name'                  => $product['title'],
    971                                     'sku'                   => (string)$product['sku'],
    972                                 )
     968                                'current_quantity'      => (string)$product['quantity'],
     969                                'product_id'            => (string)$product['id'],
     970                                'product_variant_id'    => null,
     971                                'name'                  => $product['title'],
     972                                'sku'                   => (string)$product['sku'],
     973                            )
    973974                            ) );
    974975
  • extendago-wp-connection/trunk/includes/woocommerce/class-extendago-woocommerce-functions.php

    r2940233 r2941124  
    1515        add_action( 'woocommerce_process_product_meta', array($this, 'woocommerce_extendago_product_fields_save') );
    1616
    17         add_action( 'save_post_shop_order', array($this, 'process_order_to_extendago'), 10, 3 );
     17        //add_action( 'save_post_shop_order', array($this, 'process_order_to_extendago'), 10, 3 );
    1818    }
    1919
     
    435435    }
    436436
    437 //    public function handle_update_post_shop_order($post_id, $post, $update){
    438 //
    439 //        if( $update ){
    440 //
    441 //
    442 //        }
    443 //
    444 //
    445 //        echo '<pre>';
    446 //        print_r($post_id);
    447 //        echo '</pre>';
    448 //        echo '<pre>';
    449 //        print_r($post);
    450 //        echo '</pre>';
    451 //        echo '<pre>';
    452 //        var_dump($update);
    453 //        echo '</pre>';
    454 //        exit;
    455 //
    456 //    }
    457 
    458     //public function create_extendago_new_order( $order_id, $response = false ) {
    459    public function process_order_to_extendago($order_id, $post, $update){
     437    public function create_extendago_new_order( $order_id, $response = false ) {
    460438
    461439        // Check if "New order" option is enabled
     
    470448            $logging->log_file_write('NewOrder | WebOrder status changed to: '.$order->get_status());
    471449
    472             // Update already processed orders
    473             $update_existing_order = false;
     450            // Skip already processed orders
    474451            $order_returned_successfully_to_extendago = get_post_meta($order_id, 'order_returned_successfully_to_extendago', true);
    475452            if( $order_returned_successfully_to_extendago == '1' ) {
    476                 $update_existing_order = true;
    477             }
    478             elseif( $update ){
    479                 $update_existing_order = true;
    480             }
    481 
    482             $extendago_order_id = get_post_meta($order_id, 'extendago_order_id', true);
    483             if( $update_existing_order && ( !isset($extendago_order_id) || empty($extendago_order_id)) ) {
    484                 return;
     453                return '';
    485454            }
    486455
     
    811780
    812781                // Save order
    813                 if( !$update_existing_order && isset($extendago_order_id) && !empty($extendago_order_id) ) {
    814                     $results = $web_api->createOrder($data);
    815                 }
    816                 else{
    817                     $results = $web_api->CurlRequest('/orders/'.$extendago_order_id, 'PUT', $data);
    818                 }
     782                $results = $web_api->createOrder($data);
    819783
    820784                $logging = new ExtendaGo_WP_Connection_Logging();
     
    827791                else{
    828792                    $message = 'OrderId processed: ' . $order_data['id'];
    829                     update_post_meta($order_id, 'extendago_order_id', $results['id']);
     793                    //update_post_meta($order_id, 'extendago_order_id', $results['id']);
    830794                    update_post_meta($order_id, 'order_returned_successfully_to_extendago', '1');
    831795                    update_post_meta($order_id, 'click_and_collect_order', $click_and_collect_order);
  • extendago-wp-connection/trunk/readme.txt

    r2940233 r2941124  
    55Requires at least: 6.0
    66Tested up to: 6.2.2
    7 Stable tag: 1.3.9
     7Stable tag: 1.4.0
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    3030
    3131== Changelog ==
     32
     33= 1.4.0 =
     34* Bugfix with order processing in custom cases
    3235
    3336= 1.3.9 =
Note: See TracChangeset for help on using the changeset viewer.