Fix the error of using xmlId field to link products in orders
This commit is contained in:
parent
e07cfbd1f5
commit
fa32395161
@ -405,8 +405,8 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($item['create']) && $item['create'] == true) {
|
if (isset($item['create']) && $item['create'] == true) {
|
||||||
$arItemsNew = array();
|
$arItemsNew = [];
|
||||||
$arItemsOld = array();
|
$arItemsOld = [];
|
||||||
$product = retailcrm_get_wc_product(
|
$product = retailcrm_get_wc_product(
|
||||||
$item['offer'][$this->bindField],
|
$item['offer'][$this->bindField],
|
||||||
$this->retailcrmSettings
|
$this->retailcrmSettings
|
||||||
@ -562,15 +562,21 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||||||
} else {
|
} else {
|
||||||
if (isset($item['quantity']) && $item['quantity']) {
|
if (isset($item['quantity']) && $item['quantity']) {
|
||||||
$orderItem->set_quantity($item['quantity']);
|
$orderItem->set_quantity($item['quantity']);
|
||||||
|
|
||||||
$product = retailcrm_get_wc_product($item['offer'][$this->bindField], $this->retailcrmSettings);
|
$product = retailcrm_get_wc_product($item['offer'][$this->bindField], $this->retailcrmSettings);
|
||||||
|
|
||||||
$orderItem->set_subtotal($product->get_price());
|
$orderItem->set_subtotal($product->get_price());
|
||||||
|
|
||||||
$dataStore = $orderItem->get_data_store();
|
$dataStore = $orderItem->get_data_store();
|
||||||
|
|
||||||
$dataStore->update($orderItem);
|
$dataStore->update($orderItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($item['summ']) && $item['summ']) {
|
if (isset($item['summ']) && $item['summ']) {
|
||||||
$orderItem->set_total($item['summ']);
|
$orderItem->set_total($item['summ']);
|
||||||
|
|
||||||
$dataStore = $orderItem->get_data_store();
|
$dataStore = $orderItem->get_data_store();
|
||||||
|
|
||||||
$dataStore->update($orderItem);
|
$dataStore->update($orderItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,16 +73,19 @@ class WC_Retailcrm_Order_Item extends WC_Retailcrm_Abstracts_Data
|
|||||||
*/
|
*/
|
||||||
private function set_offer(WC_Order_Item_Product $item)
|
private function set_offer(WC_Order_Item_Product $item)
|
||||||
{
|
{
|
||||||
$uid = ($item['variation_id'] > 0) ? $item['variation_id'] : $item['product_id'] ;
|
$uid = $item['variation_id'] > 0 ? $item['variation_id'] : $item['product_id'] ;
|
||||||
$offer = array('externalId' => $uid);
|
$offer = ['externalId' => $uid];
|
||||||
|
|
||||||
$product = $item->get_product();
|
$product = $item->get_product();
|
||||||
|
|
||||||
if (!empty($product) &&
|
if (
|
||||||
isset($this->settings['bind_by_sku']) &&
|
!empty($product)
|
||||||
$this->settings['bind_by_sku'] == WC_Retailcrm_Base::YES
|
&& isset($this->settings['bind_by_sku'])
|
||||||
|
&& $this->settings['bind_by_sku'] == WC_Retailcrm_Base::YES
|
||||||
) {
|
) {
|
||||||
$offer['xmlId'] = $product->get_sku();
|
$offer['xmlId'] = $product->get_sku();
|
||||||
|
|
||||||
|
unset($offer['externalId']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set_data_field('offer', $offer);
|
$this->set_data_field('offer', $offer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user