Changeset 2502500
- Timestamp:
- 03/24/2021 11:54:03 AM (5 years ago)
- Location:
- easify-server-woocommerce/trunk
- Files:
-
- 3 edited
-
easify.php (modified) (1 diff)
-
includes/class-easify-wc-shop.php (modified) (6 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easify-server-woocommerce/trunk/easify.php
r2501937 r2502500 5 5 * Plugin URI: http://www.easify.co.uk/wordpress/ 6 6 * Description: Connects Easify Business Management, EPOS (Electronic Point of Sale) and invoicing software to your WooCommerce enabled WordPress website. Allowing you to keep your online and offline shop's orders and stock control synchronised. 7 * Version: 4.2 87 * Version: 4.29 8 8 * License: GPL2 9 9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html -
easify-server-woocommerce/trunk/includes/class-easify-wc-shop.php
r2501937 r2502500 28 28 * 29 29 * @class Easify_Generic_Shop 30 * @version 4.2 830 * @version 4.29 31 31 * @package easify-woocommerce-connector 32 32 * @author Easify … … 233 233 234 234 // handling stock - we get free stock minus allocated stock 235 $stockLevel = $Product->StockLevel - $this->easify_server->get_allocation_count_by_easify_sku($Product->SKU); 236 237 // WooCommerce has a separate status value for in stock / out of stock, set it 238 // according to stock level... 239 if ($stockLevel > 0) 240 { 241 $this->DeleteOutofStockTermRelationship($ProductId); 242 update_post_meta($ProductId, '_stock_status', 'instock'); 243 } 244 else 245 { 246 update_post_meta($ProductId, '_stock_status', 'outofstock'); 247 } 235 $stock_level = $Product->StockLevel - $this->easify_server->get_allocation_count_by_easify_sku($Product->SKU); 236 237 $this->update_stock_status( $stock_level, $ProductId ); 248 238 249 239 update_post_meta($ProductId, '_manage_stock', 'yes'); … … 256 246 // This needs to be free stock level not on hand stock level (Stock level minus amount of stock allocated to other orders)... 257 247 Easify_Logging::Log("Easify_WC_Shop.UpdateProduct() - Updating stock level."); 258 update_post_meta($ProductId, '_stock', $stock Level);248 update_post_meta($ProductId, '_stock', $stock_level); 259 249 } else{ 260 250 Easify_Logging::Log("Easify_WC_Shop.UpdateProduct() - Updating of stock levels disabled."); … … 439 429 440 430 // handling stock - we get free stock minus allocated stock 441 $stock Level = $Product->StockLevel - $this->easify_server->get_allocation_count_by_easify_sku($Product->SKU);431 $stock_level = $Product->StockLevel - $this->easify_server->get_allocation_count_by_easify_sku($Product->SKU); 442 432 443 433 // get WooCommerce product id from Easify SKU 444 $ProductId = $this->GetWooCommerceProductIdFromEasifySKU($Product->SKU); 445 446 // WooCommerce has a separate status value for in stock / out of stock, set it 447 // according to stock level... 448 if ($stockLevel > 0 || $this->ProductAllowsBackorders($ProductId)) 449 { 450 $this->DeleteOutofStockTermRelationship($ProductId); 451 update_post_meta($ProductId, '_stock_status', 'instock'); 452 } 453 else 454 { 455 update_post_meta($ProductId, '_stock_status', 'outofstock'); 456 } 457 458 // This needs to be free stock level not on hand stock level (Stock level minus amount of stock allocated to other orders)... 434 $product_id = $this->GetWooCommerceProductIdFromEasifySKU($Product->SKU); 435 436 $this->update_stock_status( $stock_level, $product_id ); 437 438 // This needs to be free stock level not on hand stock level (Stock level minus amount of stock allocated to other orders). 459 439 Easify_Logging::Log("Easify_WC_Shop.UpdateProductStockLevel() - Updating stock level."); 460 update_post_meta($ ProductId, '_stock', $stockLevel);440 update_post_meta($product_id, '_stock', $stock_level); 461 441 462 442 Easify_Logging::Log("Easify_WC_Shop.UpdateProductStockLevel() - End."); … … 466 446 } 467 447 } 448 449 /** 450 * @param string $stock_level 451 * @param string|null $product_id 452 */ 453 private function update_stock_status( string $stock_level, ?string $product_id ): void { 454 // WooCommerce has a separate status value for in stock / out of stock, set it 455 // according to stock level. 456 if ( $stock_level > 0 ) { 457 Easify_Logging::Log( "Easify_WC_Shop.update_stock_status() - Stock level > 0" ); 458 459 $this->DeleteOutofStockTermRelationship( $product_id ); 460 update_post_meta( $product_id, '_stock_status', 'instock' ); 461 } else { 462 Easify_Logging::Log( "Easify_WC_Shop.update_stock_status() - Stock level == 0" ); 463 464 if ( $this->ProductAllowsBackorders( $product_id ) ) { 465 Easify_Logging::Log( "Easify_WC_Shop.update_stock_status() - Product allows back order" ); 466 467 update_post_meta( $product_id, '_stock_status', 'onbackorder' ); 468 } else { 469 Easify_Logging::Log( "Easify_WC_Shop.update_stock_status() - Product does not allow back order" ); 470 471 update_post_meta( $product_id, '_stock_status', 'outofstock' ); 472 } 473 } 474 } 468 475 469 476 public function ProductAllowsBackorders($WooProductId) { … … 1241 1248 wp_update_post($ProductStub); 1242 1249 } 1243 1244 1250 1251 1252 1253 1245 1254 } 1246 1255 -
easify-server-woocommerce/trunk/readme.txt
r2501937 r2502500 5 5 Requires at least: 4.0 6 6 Tested up to: 5.7 7 Stable tag: 4.2 87 Stable tag: 4.29 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 101 101 102 102 == Changelog == 103 = 4.29 = 104 * Additional improvements to WooCommerce stock status back order handling. 103 105 = 4.28 = 104 106 * Resolved issue where for certain configurations, WooCommerce product inventory 'Allow backorders' … … 193 195 194 196 == Upgrade Notice == 195 = 4.28 = 196 * Resolved issue where for certain configurations, WooCommerce product inventory 'Allow backorders' 197 * could be set to 'Do not allow' when product stock levels updated. 197 = 4.29 = 198 * Additional improvements to WooCommerce stock status back order handling.
Note: See TracChangeset
for help on using the changeset viewer.