Plugin Directory

Changeset 2945883


Ignore:
Timestamp:
08/01/2023 08:33:45 AM (3 years ago)
Author:
extendago
Message:

Version 1.4.1

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

Legend:

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

    r2941124 r2945883  
    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.4.0
     6Version:     1.4.1
    77Author:      Arture B.V.
    88Author URI:  https://arture.nl/
  • extendago-wp-connection/trunk/includes/api/class-extendago-web-api-functions.php

    r2935547 r2945883  
    745745            $Variation->set_attributes($variation_attributes);
    746746            $Variation->set_manage_stock('yes');
    747             $Variation->set_stock_quantity($variation['stock']);
     747
     748            if( isset($variation['stock']) ) {
     749                $Variation->set_stock_quantity($variation['stock']);
     750            }
     751            else{
     752                $Variation->set_stock_quantity(0);
     753            }
    748754
    749755            if( empty($Variation->get_sku()) || $Variation->get_sku() != $variation['sku'] ){
  • extendago-wp-connection/trunk/includes/api/class-extendago-web-api.php

    r2930779 r2945883  
    329329
    330330        if (isset($Result['id'])) return $Result['id'];
     331
    331332        return '';
    332333    }
  • extendago-wp-connection/trunk/includes/class-extendago-wp-connection-functions.php

    r2930779 r2945883  
    112112            return intval( $variation_query->posts[0] );
    113113        }
     114        else{
     115            $variation = get_post($id);
     116            if( isset($variation->ID) && $variation->post_type == 'product_variation' ){
     117                update_post_meta($id, 'extendago_size_id', $id);
     118                return $id;
     119            }
     120        }
    114121
    115122        return 0;
  • extendago-wp-connection/trunk/includes/cronjob/class-extendago-cronjob-functions.php

    r2941124 r2945883  
    640640            if( (isset($processing_export_time) && $processing_export_time >= $past_minute) ){
    641641                $this->logging->log_file_write( 'Product cronjob | Processing export files already running' );
    642                 return;
     642               return;
    643643            }
    644644
     
    852852                        }
    853853
     854
    854855                        if( empty($ProductResponse) || isset($ProductResponse['error']) ){
    855856                            $this->logging->log_file_write('EXPORT | ' . $ProductResponse['error']);
     
    878879                            else{
    879880                                $this->logging->log_file_write('EXPORT | ' . $ProductResponse['error']);
     881                            }
     882                        }
     883
     884                        // Update Extenda Go id's
     885                        if( isset($ProductResponse['product_variants']) ){
     886                            foreach( $ProductResponse['product_variants'] as $extenda_product_variant_data ){
     887
     888                                $args = array(
     889                                    'post_type'         => 'product_variation',
     890                                    'post_status'       => 'any',
     891                                    'posts_per_page'    => -1,
     892                                    'meta_query'        => array(
     893                                        array(
     894                                            'key'       => '_sku',
     895                                            'value'     => $extenda_product_variant_data['sku'],
     896                                            'compare'   => '='
     897                                        ),
     898                                    ),
     899                                    'fields' => 'ids'
     900                                );
     901                                $product_variation_query = new WP_Query($args);
     902
     903                                if( !empty($product_variation_query->posts) ) {
     904
     905                                    $found_variation_id = $product_variation_query->posts[0];
     906
     907                                    $extendago_size_id = get_post_meta($found_variation_id, 'extendago_size_id', true);
     908                                    if( $extendago_size_id != $extenda_product_variant_data['id'] ) {
     909                                        update_post_meta($found_variation_id, 'extendago_size_id', $extenda_product_variant_data['id']);
     910                                        $this->logging->log_file_write('EXPORT | Product variation ID ' . $found_variation_id . ' has new Extendago ID: ' . $extenda_product_variant_data['id']);
     911                                    }
     912                                }
     913
    880914                            }
    881915                        }
     
    933967                                $Response = $Extendago->CurlRequest('/stock_values?filter-product_variant_id='.$product_variant['id'], 'GET');
    934968
    935                                 $stock_value['reference_id'] = 'UpdateStock - webshop';
    936                                 $stock_value['stock_event_lines'] = json_encode( array( array(
    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                                 )
    943                                 ));
    944 
    945969                                if( !isset($variation->stock) || empty($variation->stock) ) {
    946970                                    $this->logging->log_file_write('EXPORT | Product variation ID ' . $product_variant['id'] . ' has no stock value!');
     
    949973
    950974                                    if( !empty($Response) ){
    951                                         if( isset($Response[0]['quantity']) && $Response[0]['quantity'] != $product['quantity'] ){
     975                                        if( isset($Response[0]['quantity']) && $Response[0]['quantity'] != $variation->stock ){
     976                                            $stock_value['reference_id'] = 'UpdateStock - webshop';
     977                                            $stock_value['stock_event_lines'] = json_encode( array( array(
     978                                                'current_quantity'      => $variation->stock,
     979                                                'product_id'            => $product['id'],
     980                                                'product_variant_id'    => $product_variant['id'],
     981                                                'name'                  => $product_variant['product_variant_name'],
     982                                                'sku'                   => $product_variant['sku'],
     983                                            )
     984                                            ));
     985
    952986                                            $Response = $Extendago->CurlRequest('/count_stock', 'POST', $stock_value, false, true);
    953987                                            $this->logging->log_file_write('EXPORT | Product variation ID ' .$product_variant['id']. ' updated to stock: ' .$variation->stock);
     
    955989                                    }
    956990                                    else{
     991
     992                                        $stock_value['reference_id'] = 'UpdateStock - webshop';
     993                                        $stock_value['stock_event_lines'] = json_encode( array( array(
     994                                            'current_quantity'      => $variation->stock,
     995                                            'product_id'            => $product['id'],
     996                                            'product_variant_id'    => $product_variant['id'],
     997                                            'name'                  => $product_variant['product_variant_name'],
     998                                            'sku'                   => $product_variant['sku'],
     999                                        )
     1000                                        ));
     1001
    9571002                                        $Response = $Extendago->CurlRequest('/count_stock', 'POST', $stock_value, false, true);
    9581003                                        $this->logging->log_file_write('EXPORT | Product variation ID ' .$product_variant['id']. ' set stock: ' .$variation->stock);
     
    14421487
    14431488        $results = $web_api->listStockChanges();
     1489
    14441490        $total_sychronized_stock_changes = 0;
    14451491        if( isset($results) && is_array($results) && !empty($results) ) {
  • extendago-wp-connection/trunk/includes/woocommerce/class-extendago-woocommerce-functions.php

    r2941124 r2945883  
    183183
    184184            // Get Product Prices
    185             $product_data['price'] = ( $product->get_price() / 100 ) * ( $default_tax + 100 );
    186 
    187             $product_regular_price = $product->get_regular_price();
    188             if( isset($product_regular_price) && !empty($product_regular_price) ){
    189                 $product_data['regular_price'] = ( $product_regular_price / 100 ) * ( $default_tax + 100 );
    190             }
    191             else{
    192                 $product_data['regular_price'] = $product_data['price'];
     185            $product_data['price'] = 0;
     186            if( $product->get_price() ) {
     187                $product_data['price'] = ($product->get_price() / 100) * ($default_tax + 100);
     188            }
     189
     190            $product_data['regular_price'] = 0;
     191            if( $product->get_regular_price() ) {
     192                $product_regular_price = $product->get_regular_price();
     193                if (isset($product_regular_price) && !empty($product_regular_price)) {
     194                    $product_data['regular_price'] = ($product_regular_price / 100) * ($default_tax + 100);
     195                } else {
     196                    $product_data['regular_price'] = $product_data['price'];
     197                }
    193198            }
    194199
  • extendago-wp-connection/trunk/readme.txt

    r2941124 r2945883  
    55Requires at least: 6.0
    66Tested up to: 6.2.2
    7 Stable tag: 1.4.0
     7Stable tag: 1.4.1
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    3030
    3131== Changelog ==
     32
     33= 1.4.1 =
     34* Some optimalisations and improvements
    3235
    3336= 1.4.0 =
Note: See TracChangeset for help on using the changeset viewer.