Plugin Directory

Changeset 3368464


Ignore:
Timestamp:
09/26/2025 12:11:01 PM (6 months ago)
Author:
extendago
Message:

Version 1.6.9

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

Legend:

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

    r3359195 r3368464  
    44Plugin URI:  https://extendago-connect.com/
    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.6.8
     6Version:     1.6.9
    77Requires Plugins: woocommerce
    88Author:      Arture B.V.
  • extendago-wp-connection/trunk/includes/api/class-extendago-web-api-functions.php

    r3359195 r3368464  
    867867        // Variation check
    868868        if( isset($stock_event_line['product_variant_id']) && !empty($stock_event_line['product_variant_id']) ){
    869             $variation_post_id = $this->functions->custom_get_variation_id_by_sku( $stock_event_line['product_variant_id'] );
     869            $variation_post_ids = $this->functions->custom_get_variation_id_by_sku( $stock_event_line['product_variant_id'] );
    870870
    871871            // Check if variation exist
    872             if (isset($variation_post_id) && !empty($variation_post_id)) {
    873                 $product_id = wp_get_post_parent_id($variation_post_id);
    874 
    875                 $this->logging->log_file_write('ExtendaGo | Processing stock change for product ' . $stock_event_line['product_id'] . '/' . $stock_event_line['product_variant_id'] . ' | ' .$product_id. ' changing stock to ' . $stock_event_line['current_quantity'] . ' (' . $stock_event_line['delta_quantity'] . ')');
    876 
    877                 if ( FALSE === get_post_status( $product_id ) ) {
    878                     $product_exist = false;
    879                 } else {
    880                     $Product = new WC_Product_Variable($product_id);
    881                     $product_exist = true;
    882                 }
    883                 $Variation = new WC_Product_Variation($variation_post_id);
    884 
    885                 // Save new product stock value
    886                 $Variation->set_stock_quantity($stock_event_line['current_quantity']);
    887 
    888                 if( $stock_event_line['current_quantity'] == 0) {
    889                     // Update stock status only when not in backorder
    890                     if (get_post_meta($variation_post_id, '_backorders', true) == 'notify' || get_post_meta($variation_post_id, '_backorders', true) == 'yes' ) {
    891                         $stock_status = 'onbackorder';
     872            if (isset($variation_post_ids) && !empty($variation_post_ids)) {
     873
     874                foreach( $variation_post_ids as $variation_post_id ) {
     875                    $product_id = wp_get_post_parent_id($variation_post_id);
     876
     877                    $this->logging->log_file_write('ExtendaGo | Processing stock change for product ' . $stock_event_line['product_id'] . '/' . $stock_event_line['product_variant_id'] . ' | ' . $product_id . ' changing stock to ' . $stock_event_line['current_quantity'] . ' (' . $stock_event_line['delta_quantity'] . ')');
     878
     879                    if (FALSE === get_post_status($product_id)) {
     880                        $product_exist = false;
     881                    } else {
     882                        $Product = new WC_Product_Variable($product_id);
     883                        $product_exist = true;
    892884                    }
    893                     else{
     885                    $Variation = new WC_Product_Variation($variation_post_id);
     886
     887                    // Save new product stock value
     888                    $Variation->set_stock_quantity($stock_event_line['current_quantity']);
     889
     890                    if ($stock_event_line['current_quantity'] == 0) {
     891                        // Update stock status only when not in backorder
     892                        if (get_post_meta($variation_post_id, '_backorders', true) == 'notify' || get_post_meta($variation_post_id, '_backorders', true) == 'yes') {
     893                            $stock_status = 'onbackorder';
     894                        } else {
     895                            $stock_status = 'outofstock';
     896                            $Variation->set_backorders('no');
     897                        }
     898                    } else {
     899                        $stock_status = 'instock';
     900                    }
     901
     902                    $Variation->save();
     903
     904                    // Check if all variatons are out of stock
     905                    if (is_null(get_post($product_id))) {
     906                        $this->logging->log_file_write('NOTICE | Product ID ' . $product_id . ' no longer exist');
     907                    } else {
     908                        $all_product_variations = $Product->get_children();
    894909                        $stock_status = 'outofstock';
    895                         $Variation->set_backorders('no');
    896                     }
    897                 } else {
    898                     $stock_status = 'instock';
    899                 }
    900 
    901                 $Variation->save();
    902 
    903                 // Check if all variatons are out of stock
    904                 if( is_null( get_post($product_id) ) ) {
    905                     $this->logging->log_file_write( 'NOTICE | Product ID '.$product_id.' no longer exist' );
    906                 }
    907                 else {
    908                     $all_product_variations = $Product->get_children();
    909                     $stock_status = 'outofstock';
    910                     if (isset($all_product_variations) && !empty($all_product_variations)) {
    911                         foreach ($all_product_variations as $variation_post_id) {
    912                             $single_variation = new WC_Product_Variation($variation_post_id);
    913                             $variation_stock_amount = $single_variation->get_stock_quantity();
    914 
    915                             if ($variation_stock_amount > 0) {
    916                                 $stock_status = 'instock';
     910                        if (isset($all_product_variations) && !empty($all_product_variations)) {
     911                            foreach ($all_product_variations as $variation_post_id) {
     912                                $single_variation = new WC_Product_Variation($variation_post_id);
     913                                $variation_stock_amount = $single_variation->get_stock_quantity();
     914
     915                                if ($variation_stock_amount > 0) {
     916                                    $stock_status = 'instock';
     917                                }
    917918                            }
     919
    918920                        }
    919 
    920921                    }
    921922                }
     
    932933            if (isset($product_id) && !empty($product_id)) {
    933934
    934                 $this->logging->log_file_write('ExtendaGo | Processing stock change for product ' . $stock_event_line['product_id'] . ' | ' .$product_id. ' changing stock to ' . $stock_event_line['current_quantity'] . ' (' . $stock_event_line['delta_quantity'] . ') Product ID not found!');
     935                $this->logging->log_file_write('ExtendaGo | Processing stock change for product ' . $stock_event_line['product_id'] . ' | ' .$product_id. ' changing stock to ' . $stock_event_line['current_quantity'] . ' (' . $stock_event_line['delta_quantity'] . ')');
    935936
    936937                $Product = wc_get_product( $product_id );
  • extendago-wp-connection/trunk/includes/api/class-extendago-web-api.php

    r3257883 r3368464  
    132132                }
    133133            }
    134             if (count($Results) == $Limit) {
    135                 $HasMore = true;
    136                 $Offset += $Limit;
     134            if( !empty($Results) ) {
     135                if (count($Results) == $Limit) {
     136                    $HasMore = true;
     137                    $Offset += $Limit;
     138                }
    137139            }
    138140        }
     
    154156            $HasMore = false;
    155157            $Results = $this->CurlRequest("/products", "GET", array("limit" => $Limit, "offset" => $Offset));
    156 
    157 
    158158            foreach ($Results as $Result) {
    159159                if (isset($Result['id'])) {
     
    161161                }
    162162            }
    163             if (count($Results) == $Limit) {
    164                 $HasMore = true;
    165                 $Offset += $Limit;
     163            if( !empty($Results) ) {
     164                if (count($Results) == $Limit) {
     165                    $HasMore = true;
     166                    $Offset += $Limit;
     167                }
    166168            }
    167169        }
     
    188190                }
    189191            }
    190             if (count($Results) == $Limit) {
    191                 $HasMore = true;
    192                 $Offset += $Limit;
     192            if( !empty($Results) ) {
     193                if (count($Results) == $Limit) {
     194                    $HasMore = true;
     195                    $Offset += $Limit;
     196                }
    193197            }
    194198        }
     
    234238                }
    235239            }
    236             if (count($Results) == $Limit) {
    237                 $HasMore = true;
    238                 $Offset += $Limit;
     240            if( !empty($Results) ) {
     241                if (count($Results) == $Limit) {
     242                    $HasMore = true;
     243                    $Offset += $Limit;
     244                }
    239245            }
    240246        }
     
    255261                }
    256262            }
    257             if (count($Results) == $Limit) {
    258                 $HasMore = true;
    259                 $Offset += $Limit;
     263            if( !empty($Results) ) {
     264                if (count($Results) == $Limit) {
     265                    $HasMore = true;
     266                    $Offset += $Limit;
     267                }
    260268            }
    261269        }
     
    305313                }
    306314            }
     315            if( !empty($Results) ) {
     316                if (count($Results) == $Limit) {
     317                    $HasMore = true;
     318                    $Offset += $Limit;
     319                }
     320            }
     321        }
     322        return $PromotionCampaigns;
     323    }
     324
     325    public function listOrders($AfterOrder = NULL) {
     326        $Offset = 0;
     327        $Limit = 250;
     328        $HasMore = true;
     329        $Orders = array();
     330        while ($HasMore) {
     331            $HasMore = false;
     332            $Results = $this->CurlRequest("/orders", "GET", array("sort" => "timestamp", "limit" => $Limit, "offset" => $Offset));
     333            foreach ($Results as $Result) {
     334                if (isset($Result['id'])) {
     335                    if ($AfterOrder !== NULL && $Result['id'] == $AfterOrder) return $Orders;
     336                    $Orders[] = $Result;
     337                }
     338            }
     339            if( !empty($Results) ) {
     340                if (count($Results) == $Limit) {
     341                    $HasMore = true;
     342                    $Offset += $Limit;
     343                }
     344            }
     345        }
     346        return $Orders;
     347    }
     348
     349    public function getOrder($OrderID) {
     350        $Result = $this->CurlRequest("/orders/".$OrderID);
     351        if (isset($Result['id'])) return $Result;
     352        return NULL;
     353    }
     354
     355    public function deleteOrder($OrderID) {
     356        $Result = $this->CurlRequest("/orders/".$OrderID, "DELETE");
     357        return (isset($Result['success']) && $Result['success']);
     358    }
     359
     360    public function createOrder($params) {
     361        $Result = $this->CurlRequest("/orders", "POST", $params);
     362
     363        if (isset($Result['id'])) return $Result['id'];
     364
     365        return '';
     366    }
     367
     368    public function listShippingMethods() {
     369        $Offset = 0;
     370        $Limit = 250;
     371        $HasMore = true;
     372        $ShippingMethods = array();
     373        while ($HasMore) {
     374            $HasMore = false;
     375            $Results = $this->CurlRequest("/shipping_methods", "GET", array("limit" => $Limit, "offset" => $Offset));
     376            foreach ($Results as $Result) {
     377                if (isset($Result['id'])) {
     378                    $ShippingMethods[] = $Result;
     379                }
     380            }
     381            if( !empty($Results) ) {
     382                if (count($Results) == $Limit) {
     383                    $HasMore = true;
     384                    $Offset += $Limit;
     385                }
     386            }
     387        }
     388        return $ShippingMethods;
     389    }
     390
     391    public function listPaymentSubscriptions() {
     392        $Offset = 0;
     393        $Limit = 250;
     394        $HasMore = true;
     395        $PaymentSubscriptions = array();
     396        while ($HasMore) {
     397            $HasMore = false;
     398            $Results = $this->CurlRequest("/payment_subscriptions", "GET", array("limit" => $Limit, "offset" => $Offset));
     399            foreach ($Results as $Result) {
     400                if (isset($Result['id'])) {
     401                    $PaymentSubscriptions[] = $Result;
     402                }
     403            }
     404            if( !empty($Results) ) {
     405                if (count($Results) == $Limit) {
     406                    $HasMore = true;
     407                    $Offset += $Limit;
     408                }
     409            }
     410        }
     411        return $PaymentSubscriptions;
     412    }
     413
     414    public function listCustomers() {
     415        $Offset = 0;
     416        $Limit = 250;
     417        $HasMore = true;
     418        $Customers = array();
     419        while ($HasMore) {
     420            $HasMore = false;
     421            $Results = $this->CurlRequest("/customers", "GET", array("limit" => $Limit, "offset" => $Offset));
     422            foreach ($Results as $Result) {
     423                if (isset($Result['id'])) {
     424                    $Customers[] = $Result;
     425                }
     426            }
    307427            if (count($Results) == $Limit) {
    308428                $HasMore = true;
     
    310430            }
    311431        }
    312         return $PromotionCampaigns;
    313     }
    314 
    315     public function listOrders($AfterOrder = NULL) {
    316         $Offset = 0;
    317         $Limit = 250;
    318         $HasMore = true;
    319         $Orders = array();
    320         while ($HasMore) {
    321             $HasMore = false;
    322             $Results = $this->CurlRequest("/orders", "GET", array("sort" => "timestamp", "limit" => $Limit, "offset" => $Offset));
    323             foreach ($Results as $Result) {
    324                 if (isset($Result['id'])) {
    325                     if ($AfterOrder !== NULL && $Result['id'] == $AfterOrder) return $Orders;
    326                     $Orders[] = $Result;
    327                 }
    328             }
    329             if (count($Results) == $Limit) {
    330                 $HasMore = true;
    331                 $Offset += $Limit;
    332             }
    333         }
    334         return $Orders;
    335     }
    336 
    337     public function getOrder($OrderID) {
    338         $Result = $this->CurlRequest("/orders/".$OrderID);
    339         if (isset($Result['id'])) return $Result;
    340         return NULL;
    341     }
    342 
    343     public function deleteOrder($OrderID) {
    344         $Result = $this->CurlRequest("/orders/".$OrderID, "DELETE");
    345         return (isset($Result['success']) && $Result['success']);
    346     }
    347 
    348     public function createOrder($params) {
    349         $Result = $this->CurlRequest("/orders", "POST", $params);
    350 
    351         if (isset($Result['id'])) return $Result['id'];
    352 
    353         return '';
    354     }
    355 
    356     public function listShippingMethods() {
    357         $Offset = 0;
    358         $Limit = 250;
    359         $HasMore = true;
    360         $ShippingMethods = array();
    361         while ($HasMore) {
    362             $HasMore = false;
    363             $Results = $this->CurlRequest("/shipping_methods", "GET", array("limit" => $Limit, "offset" => $Offset));
    364             foreach ($Results as $Result) {
    365                 if (isset($Result['id'])) {
    366                     $ShippingMethods[] = $Result;
    367                 }
    368             }
    369             if (count($Results) == $Limit) {
    370                 $HasMore = true;
    371                 $Offset += $Limit;
    372             }
    373         }
    374         return $ShippingMethods;
    375     }
    376 
    377     public function listPaymentSubscriptions() {
    378         $Offset = 0;
    379         $Limit = 250;
    380         $HasMore = true;
    381         $PaymentSubscriptions = array();
    382         while ($HasMore) {
    383             $HasMore = false;
    384             $Results = $this->CurlRequest("/payment_subscriptions", "GET", array("limit" => $Limit, "offset" => $Offset));
    385             foreach ($Results as $Result) {
    386                 if (isset($Result['id'])) {
    387                     $PaymentSubscriptions[] = $Result;
    388                 }
    389             }
    390             if (count($Results) == $Limit) {
    391                 $HasMore = true;
    392                 $Offset += $Limit;
    393             }
    394         }
    395         return $PaymentSubscriptions;
    396     }
    397 
    398     public function listCustomers() {
    399         $Offset = 0;
    400         $Limit = 250;
    401         $HasMore = true;
    402         $Customers = array();
    403         while ($HasMore) {
    404             $HasMore = false;
    405             $Results = $this->CurlRequest("/customers", "GET", array("limit" => $Limit, "offset" => $Offset));
    406             foreach ($Results as $Result) {
    407                 if (isset($Result['id'])) {
    408                     $Customers[] = $Result;
    409                 }
    410             }
    411             if (count($Results) == $Limit) {
    412                 $HasMore = true;
    413                 $Offset += $Limit;
    414             }
    415         }
    416432        return $Customers;
    417433    }
  • extendago-wp-connection/trunk/includes/class-extendago-wp-connection-functions.php

    r3212240 r3368464  
    116116        $args = array(
    117117            'post_type' => 'product_variation',
    118             'posts_per_page' => 1,
     118            'posts_per_page' => -1,
    119119            'meta_query' => array(
    120120                array(
     
    127127        $variation_query = new WP_Query($args);
    128128        if( isset($variation_query->posts) && !empty($variation_query->posts) ){
    129             return intval( $variation_query->posts[0] );
     129            return $variation_query->posts;
    130130        }
    131131        else{
     
    133133            if( isset($variation->ID) && $variation->post_type == 'product_variation' ){
    134134                update_post_meta($id, 'extendago_size_id', $id);
    135                 return $id;
     135                return (array)$id;
    136136            }
    137137        }
    138138
    139         return 0;
     139        return [];
    140140    }
    141141
  • extendago-wp-connection/trunk/readme.txt

    r3359195 r3368464  
    44Tags: extendago, extenda, woocommerce, arture, POS,
    55Requires at least: 6.0
    6 Tested up to: 6.8.1
    7 Stable tag: 1.6.8
    8 Requires PHP: 7.4
     6Tested up to: 6.8.2
     7Stable tag: 1.6.9
     8Requires PHP: 8.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3232
    3333= 1.6.9 =
     34* Fallback function for hidden/abanded variations with stock updates
     35* Bugfix with valid connection but without any results
     36
     37= 1.6.8 =
    3438* Single product import batch changed with product ID
    35 
    36 = 1.6.8 =
    3739* Bugfix for simple product updates with stock
    3840
Note: See TracChangeset for help on using the changeset viewer.