1
0
mirror of synced 2025-02-20 08:53:14 +03:00

The method for determining the stock quantity has been optimized (#354)

This commit is contained in:
Uryvskiy Dima 2024-11-11 16:50:57 +03:00 committed by GitHub
parent 6e39fca72c
commit cdc7ca71bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 23 additions and 14 deletions

View File

@ -1,3 +1,6 @@
## 2024-11-07 4.8.14
* The method for determining the stock quantity has been optimized
## 2024-11-07 4.8.13
* Supports custom cart and checkout templates

View File

@ -1 +1 @@
4.8.13
4.8.14

View File

@ -253,13 +253,6 @@ if (!class_exists('WC_Retailcrm_Icml')) :
$tax = reset($tax_rates);
}
if ($product->get_manage_stock() == true) {
$stockQuantity = $product->get_stock_quantity();
$quantity = empty($stockQuantity) === false ? $stockQuantity : 0;
} else {
$quantity = $product->get_stock_status() === 'instock' ? 1 : 0;
}
$productData = [
'id' => $product->get_id(),
'productId' => ($product->get_parent_id() > 0) ? $parent->get_id() : $product->get_id(),
@ -271,7 +264,7 @@ if (!class_exists('WC_Retailcrm_Icml')) :
,
'picture' => $images,
'url' => ($product->get_parent_id() > 0) ? $parent->get_permalink() : $product->get_permalink(),
'quantity' => $quantity,
'quantity' => $this->getQuantity($product),
'categoryId' => $termList,
'dimensions' => $dimensions,
'weight' => $weight,
@ -309,9 +302,19 @@ if (!class_exists('WC_Retailcrm_Icml')) :
$product
);
if (isset($productData)) {
return $productData;
return $productData ?? [];
}
private function getQuantity($product)
{
if ($product->get_manage_stock()) {
$stockQuantity = $product->get_stock_quantity();
$quantity = $stockQuantity !== null && $stockQuantity !== 0 ? $stockQuantity : 0;
} else {
$quantity = $product->get_stock_status() === 'instock' ? 1 : 0;
}
return $quantity;
}
/**

View File

@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla
Requires PHP: 7.1
Requires at least: 5.3
Tested up to: 6.5
Stable tag: 4.8.13
Stable tag: 4.8.14
License: GPLv1 or later
License URI: http://www.gnu.org/licenses/gpl-1.0.html
@ -82,6 +82,9 @@ Asegúrate de tener una clave API específica para cada tienda. Las siguientes i
== Changelog ==
= 4.8.14 =
* The method for determining the stock quantity has been optimized
= 4.8.13 =
* Supports custom cart and checkout templates

View File

@ -5,7 +5,7 @@
* Description: Integration plugin for WooCommerce & Simla.com
* Author: RetailDriver LLC
* Author URI: http://retailcrm.pro/
* Version: 4.8.13
* Version: 4.8.14
* Tested up to: 6.5
* Requires Plugins: woocommerce
* WC requires at least: 5.4

View File

@ -16,7 +16,7 @@
*
* @link https://wordpress.org/plugins/woo-retailcrm/
*
* @version 4.8.13
* @version 4.8.14
*
* @package RetailCRM
*/