diff --git a/src/include/class-wc-retailcrm-inventories.php b/src/include/class-wc-retailcrm-inventories.php index 3e1fa10..894cfc4 100644 --- a/src/include/class-wc-retailcrm-inventories.php +++ b/src/include/class-wc-retailcrm-inventories.php @@ -52,8 +52,8 @@ if (!class_exists('WC_Retailcrm_Inventories')) : return null; } - $page = 1; - $variationProducts = array(); + $page = 1; + $variationProducts = array(); do { /** @var WC_Retailcrm_Response $result */ @@ -70,31 +70,31 @@ if (!class_exists('WC_Retailcrm_Inventories')) : if (isset($offer[$this->bind_field])) { $product = retailcrm_get_wc_product($offer[$this->bind_field], $this->retailcrm_settings); - if ($product instanceof WC_Product) { - if ($product->get_type() == 'variation' || $product->get_type() == 'variable') { - $parentId = $product->get_parent_id(); + if ($product instanceof WC_Product) { + if ($product->get_type() == 'variation' || $product->get_type() == 'variable') { + $parentId = $product->get_parent_id(); - if (isset($variationProducts[$parentId])) { - $variationProducts[$parentId] += $offer['quantity']; - } else { - $variationProducts[$parentId] = $offer['quantity']; - } - } + if (isset($variationProducts[$parentId])) { + $variationProducts[$parentId] += $offer['quantity']; + } else { + $variationProducts[$parentId] = $offer['quantity']; + } + } - $product->set_manage_stock(true); - $product->set_stock_quantity($offer['quantity']); - $success[] = $product->save(); - } - } - } + $product->set_manage_stock(true); + $product->set_stock_quantity($offer['quantity']); + $success[] = $product->save(); + } + } + } - foreach ($variationProducts as $id => $quantity) { - $variationProduct = wc_get_product($id); - $variationProduct->set_manage_stock(true); - $variationProduct->set_stock($quantity); - $success[] = $variationProduct->save(); - } - } while ($page <= $totalPageCount); + foreach ($variationProducts as $id => $quantity) { + $variationProduct = wc_get_product($id); + $variationProduct->set_manage_stock(true); + $variationProduct->set_stock($quantity); + $success[] = $variationProduct->save(); + } + } while ($page <= $totalPageCount); return $success; }