Plugin Directory

Changeset 3035750


Ignore:
Timestamp:
02/14/2024 03:16:04 PM (2 years ago)
Author:
postiwp
Message:

Update to version 2.4.4 from GitHub

Location:
posti-warehouse
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • posti-warehouse/tags/2.4.4/README.md

    r3035708 r3035750  
    9797
    9898## Version history
     99- 2.4.4: Bug fix: re-merge Reject partial order.
    99100- 2.4.3: Bug fix: Some quantity and order status updates were being skipped because get_posts is implicitly limited to 5 results by default.
    100101- 2.4.2: Added "Verbose logging" setting.
  • posti-warehouse/tags/2.4.4/classes/class-api.php

    r3035708 r3035750  
    1414    private $last_status = false;
    1515    private $token_option = 'posti_wh_api_auth';
    16     private $user_agent = 'woo-wh-client/2.4.3';
     16    private $user_agent = 'woo-wh-client/2.4.4';
    1717
    1818    public function __construct(Posti_Warehouse_Logger $logger, array &$options) {
  • posti-warehouse/tags/2.4.4/classes/class-order.php

    r3035708 r3035750  
    7171            $order = wc_get_order($order);
    7272        }
     73       
    7374        if (!$order) {
    7475            return false;
    7576        }
     77       
    7678        $items = $order->get_items();
     79        if (count($items) == 0) {
     80            return false;
     81        }
     82       
    7783        foreach ($items as $item_id => $item) {
    78             $product_warehouse = get_post_meta($item['product_id'], '_posti_wh_warehouse', true);
    79             $type = $this->product->get_stock_type_by_warehouse($product_warehouse);
    80             if ('Posti' === $type || 'Store' === $type || 'Catalog' === $type) {
     84            if ($this->product->has_known_stock_type($item['product_id'])) {
    8185                return true;
    8286            }
    8387        }
    84 
     88       
    8589        return false;
     90    }
     91   
     92    public function hasPostiProductsOnly( $order) {
     93        if (!is_object($order)) {
     94            $order = wc_get_order($order);
     95        }
     96       
     97        if (!$order) {
     98            return false;
     99        }
     100       
     101        $items = $order->get_items();
     102        if (count($items) == 0) {
     103            return false;
     104        }
     105       
     106        foreach ($items as $item_id => $item) {
     107            if (!$this->product->has_known_stock_type($item['product_id'])) {
     108                return false;
     109            }
     110        }
     111       
     112        return true;
    86113    }
    87114
     
    95122
    96123    public function addOrder( $order) {
     124        $options = Posti_Warehouse_Settings::get();
     125        return $this->addOrderWithOptions($order, $options);
     126    }
     127   
     128    public function addOrderWithOptions( $order, $options) {
    97129        if (!is_object($order)) {
    98130            $order = wc_get_order($order);
     131        }
     132       
     133        if (Posti_Warehouse_Settings::is_reject_partial_orders($options) && !$this->hasPostiProductsOnly($order)) {
     134            return [ 'error' => 'ERROR: Partial order not allowed.' ];
    99135        }
    100136
     
    192228        );
    193229        $posts = get_posts($posts_query);
     230        if (count($posts) == 0) {
     231            if ($is_verbose) {
     232                $this->logger->log('info', "No matched orders for status update");
     233            }
     234
     235            return true;
     236        }
     237       
    194238        if ($is_verbose) {
    195239            $matched_post_ids = array();
     
    198242            }
    199243            $this->logger->log('info', "Matched orders: " . implode(', ', $matched_post_ids));
    200         }
    201        
    202         if (count($posts) == 0) {
    203             if ($is_verbose) {
    204                 $this->logger->log('info', "No matched orders for status update");
    205             }
    206 
    207             return true;
    208244        }
    209245       
  • posti-warehouse/tags/2.4.4/classes/class-product.php

    r3035708 r3035750  
    749749        $product_ids = array_unique($product_ids_tmp);
    750750
     751        $options = Posti_Warehouse_Settings::get();
     752        $is_verbose = Posti_Warehouse_Settings::is_verbose_logging($options);
     753        if ($is_verbose) {
     754            $this->logger->log('info', "Got inventory updates for: " . implode(', ', $product_ids_tmp));
     755        }
     756       
    751757        $posts_query = array(
    752758            'post_type' => ['product', 'product_variation'],
     
    762768        $posts = get_posts($posts_query);
    763769        if (0 == count($posts)) {
     770            if ($is_verbose) {
     771                $this->logger->log('info', "No matched products for inventory update");
     772            }
     773           
    764774            return;
     775        }
     776
     777        if ($is_verbose) {
     778            $matched_post_ids = array();
     779            foreach ($posts as $post) {
     780                array_push($matched_post_ids, (string) $post->ID);
     781            }
     782            $this->logger->log('info', "Matched products: " . implode(', ', $matched_post_ids));
    765783        }
    766784
  • posti-warehouse/tags/2.4.4/posti-warehouse.php

    r3035708 r3035750  
    33/**
    44 * Plugin Name: Posti Warehouse
    5  * Version: 2.4.3
     5 * Version: 2.4.4
    66 * Description: Provides integration to Posti warehouse and dropshipping services.
    77 * Author: Posti
  • posti-warehouse/tags/2.4.4/readme.txt

    r3035708 r3035750  
    55Tested up to: 6.4.2
    66Requires PHP: 7.1
    7 Stable tag: 2.4.3
     7Stable tag: 2.4.4
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
  • posti-warehouse/trunk/README.md

    r3035708 r3035750  
    9797
    9898## Version history
     99- 2.4.4: Bug fix: re-merge Reject partial order.
    99100- 2.4.3: Bug fix: Some quantity and order status updates were being skipped because get_posts is implicitly limited to 5 results by default.
    100101- 2.4.2: Added "Verbose logging" setting.
  • posti-warehouse/trunk/classes/class-api.php

    r3035708 r3035750  
    1414    private $last_status = false;
    1515    private $token_option = 'posti_wh_api_auth';
    16     private $user_agent = 'woo-wh-client/2.4.3';
     16    private $user_agent = 'woo-wh-client/2.4.4';
    1717
    1818    public function __construct(Posti_Warehouse_Logger $logger, array &$options) {
  • posti-warehouse/trunk/classes/class-order.php

    r3035708 r3035750  
    7171            $order = wc_get_order($order);
    7272        }
     73       
    7374        if (!$order) {
    7475            return false;
    7576        }
     77       
    7678        $items = $order->get_items();
     79        if (count($items) == 0) {
     80            return false;
     81        }
     82       
    7783        foreach ($items as $item_id => $item) {
    78             $product_warehouse = get_post_meta($item['product_id'], '_posti_wh_warehouse', true);
    79             $type = $this->product->get_stock_type_by_warehouse($product_warehouse);
    80             if ('Posti' === $type || 'Store' === $type || 'Catalog' === $type) {
     84            if ($this->product->has_known_stock_type($item['product_id'])) {
    8185                return true;
    8286            }
    8387        }
    84 
     88       
    8589        return false;
     90    }
     91   
     92    public function hasPostiProductsOnly( $order) {
     93        if (!is_object($order)) {
     94            $order = wc_get_order($order);
     95        }
     96       
     97        if (!$order) {
     98            return false;
     99        }
     100       
     101        $items = $order->get_items();
     102        if (count($items) == 0) {
     103            return false;
     104        }
     105       
     106        foreach ($items as $item_id => $item) {
     107            if (!$this->product->has_known_stock_type($item['product_id'])) {
     108                return false;
     109            }
     110        }
     111       
     112        return true;
    86113    }
    87114
     
    95122
    96123    public function addOrder( $order) {
     124        $options = Posti_Warehouse_Settings::get();
     125        return $this->addOrderWithOptions($order, $options);
     126    }
     127   
     128    public function addOrderWithOptions( $order, $options) {
    97129        if (!is_object($order)) {
    98130            $order = wc_get_order($order);
     131        }
     132       
     133        if (Posti_Warehouse_Settings::is_reject_partial_orders($options) && !$this->hasPostiProductsOnly($order)) {
     134            return [ 'error' => 'ERROR: Partial order not allowed.' ];
    99135        }
    100136
     
    192228        );
    193229        $posts = get_posts($posts_query);
     230        if (count($posts) == 0) {
     231            if ($is_verbose) {
     232                $this->logger->log('info', "No matched orders for status update");
     233            }
     234
     235            return true;
     236        }
     237       
    194238        if ($is_verbose) {
    195239            $matched_post_ids = array();
     
    198242            }
    199243            $this->logger->log('info', "Matched orders: " . implode(', ', $matched_post_ids));
    200         }
    201        
    202         if (count($posts) == 0) {
    203             if ($is_verbose) {
    204                 $this->logger->log('info', "No matched orders for status update");
    205             }
    206 
    207             return true;
    208244        }
    209245       
  • posti-warehouse/trunk/classes/class-product.php

    r3035708 r3035750  
    749749        $product_ids = array_unique($product_ids_tmp);
    750750
     751        $options = Posti_Warehouse_Settings::get();
     752        $is_verbose = Posti_Warehouse_Settings::is_verbose_logging($options);
     753        if ($is_verbose) {
     754            $this->logger->log('info', "Got inventory updates for: " . implode(', ', $product_ids_tmp));
     755        }
     756       
    751757        $posts_query = array(
    752758            'post_type' => ['product', 'product_variation'],
     
    762768        $posts = get_posts($posts_query);
    763769        if (0 == count($posts)) {
     770            if ($is_verbose) {
     771                $this->logger->log('info', "No matched products for inventory update");
     772            }
     773           
    764774            return;
     775        }
     776
     777        if ($is_verbose) {
     778            $matched_post_ids = array();
     779            foreach ($posts as $post) {
     780                array_push($matched_post_ids, (string) $post->ID);
     781            }
     782            $this->logger->log('info', "Matched products: " . implode(', ', $matched_post_ids));
    765783        }
    766784
  • posti-warehouse/trunk/posti-warehouse.php

    r3035708 r3035750  
    33/**
    44 * Plugin Name: Posti Warehouse
    5  * Version: 2.4.3
     5 * Version: 2.4.4
    66 * Description: Provides integration to Posti warehouse and dropshipping services.
    77 * Author: Posti
  • posti-warehouse/trunk/readme.txt

    r3035708 r3035750  
    55Tested up to: 6.4.2
    66Requires PHP: 7.1
    7 Stable tag: 2.4.3
     7Stable tag: 2.4.4
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset for help on using the changeset viewer.