Changeset 3035750
- Timestamp:
- 02/14/2024 03:16:04 PM (2 years ago)
- Location:
- posti-warehouse
- Files:
-
- 12 edited
- 1 copied
-
tags/2.4.4 (copied) (copied from posti-warehouse/trunk)
-
tags/2.4.4/README.md (modified) (1 diff)
-
tags/2.4.4/classes/class-api.php (modified) (1 diff)
-
tags/2.4.4/classes/class-order.php (modified) (4 diffs)
-
tags/2.4.4/classes/class-product.php (modified) (2 diffs)
-
tags/2.4.4/posti-warehouse.php (modified) (1 diff)
-
tags/2.4.4/readme.txt (modified) (1 diff)
-
trunk/README.md (modified) (1 diff)
-
trunk/classes/class-api.php (modified) (1 diff)
-
trunk/classes/class-order.php (modified) (4 diffs)
-
trunk/classes/class-product.php (modified) (2 diffs)
-
trunk/posti-warehouse.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
posti-warehouse/tags/2.4.4/README.md
r3035708 r3035750 97 97 98 98 ## Version history 99 - 2.4.4: Bug fix: re-merge Reject partial order. 99 100 - 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. 100 101 - 2.4.2: Added "Verbose logging" setting. -
posti-warehouse/tags/2.4.4/classes/class-api.php
r3035708 r3035750 14 14 private $last_status = false; 15 15 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'; 17 17 18 18 public function __construct(Posti_Warehouse_Logger $logger, array &$options) { -
posti-warehouse/tags/2.4.4/classes/class-order.php
r3035708 r3035750 71 71 $order = wc_get_order($order); 72 72 } 73 73 74 if (!$order) { 74 75 return false; 75 76 } 77 76 78 $items = $order->get_items(); 79 if (count($items) == 0) { 80 return false; 81 } 82 77 83 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'])) { 81 85 return true; 82 86 } 83 87 } 84 88 85 89 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; 86 113 } 87 114 … … 95 122 96 123 public function addOrder( $order) { 124 $options = Posti_Warehouse_Settings::get(); 125 return $this->addOrderWithOptions($order, $options); 126 } 127 128 public function addOrderWithOptions( $order, $options) { 97 129 if (!is_object($order)) { 98 130 $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.' ]; 99 135 } 100 136 … … 192 228 ); 193 229 $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 194 238 if ($is_verbose) { 195 239 $matched_post_ids = array(); … … 198 242 } 199 243 $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;208 244 } 209 245 -
posti-warehouse/tags/2.4.4/classes/class-product.php
r3035708 r3035750 749 749 $product_ids = array_unique($product_ids_tmp); 750 750 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 751 757 $posts_query = array( 752 758 'post_type' => ['product', 'product_variation'], … … 762 768 $posts = get_posts($posts_query); 763 769 if (0 == count($posts)) { 770 if ($is_verbose) { 771 $this->logger->log('info', "No matched products for inventory update"); 772 } 773 764 774 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)); 765 783 } 766 784 -
posti-warehouse/tags/2.4.4/posti-warehouse.php
r3035708 r3035750 3 3 /** 4 4 * Plugin Name: Posti Warehouse 5 * Version: 2.4. 35 * Version: 2.4.4 6 6 * Description: Provides integration to Posti warehouse and dropshipping services. 7 7 * Author: Posti -
posti-warehouse/tags/2.4.4/readme.txt
r3035708 r3035750 5 5 Tested up to: 6.4.2 6 6 Requires PHP: 7.1 7 Stable tag: 2.4. 37 Stable tag: 2.4.4 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html -
posti-warehouse/trunk/README.md
r3035708 r3035750 97 97 98 98 ## Version history 99 - 2.4.4: Bug fix: re-merge Reject partial order. 99 100 - 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. 100 101 - 2.4.2: Added "Verbose logging" setting. -
posti-warehouse/trunk/classes/class-api.php
r3035708 r3035750 14 14 private $last_status = false; 15 15 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'; 17 17 18 18 public function __construct(Posti_Warehouse_Logger $logger, array &$options) { -
posti-warehouse/trunk/classes/class-order.php
r3035708 r3035750 71 71 $order = wc_get_order($order); 72 72 } 73 73 74 if (!$order) { 74 75 return false; 75 76 } 77 76 78 $items = $order->get_items(); 79 if (count($items) == 0) { 80 return false; 81 } 82 77 83 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'])) { 81 85 return true; 82 86 } 83 87 } 84 88 85 89 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; 86 113 } 87 114 … … 95 122 96 123 public function addOrder( $order) { 124 $options = Posti_Warehouse_Settings::get(); 125 return $this->addOrderWithOptions($order, $options); 126 } 127 128 public function addOrderWithOptions( $order, $options) { 97 129 if (!is_object($order)) { 98 130 $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.' ]; 99 135 } 100 136 … … 192 228 ); 193 229 $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 194 238 if ($is_verbose) { 195 239 $matched_post_ids = array(); … … 198 242 } 199 243 $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;208 244 } 209 245 -
posti-warehouse/trunk/classes/class-product.php
r3035708 r3035750 749 749 $product_ids = array_unique($product_ids_tmp); 750 750 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 751 757 $posts_query = array( 752 758 'post_type' => ['product', 'product_variation'], … … 762 768 $posts = get_posts($posts_query); 763 769 if (0 == count($posts)) { 770 if ($is_verbose) { 771 $this->logger->log('info', "No matched products for inventory update"); 772 } 773 764 774 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)); 765 783 } 766 784 -
posti-warehouse/trunk/posti-warehouse.php
r3035708 r3035750 3 3 /** 4 4 * Plugin Name: Posti Warehouse 5 * Version: 2.4. 35 * Version: 2.4.4 6 6 * Description: Provides integration to Posti warehouse and dropshipping services. 7 7 * Author: Posti -
posti-warehouse/trunk/readme.txt
r3035708 r3035750 5 5 Tested up to: 6.4.2 6 6 Requires PHP: 7.1 7 Stable tag: 2.4. 37 Stable tag: 2.4.4 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset
for help on using the changeset viewer.