← All changes
|
includes/Services/Products/Discount/VariableProductDiscount.php
+4
-5
1.10.19
→
1.10.28
View file →
| @@ -17,10 +17,10 @@ | ||
| 17 | 17 | { |
| 18 | 18 | foreach ($product->get_children() as $variation_id) { |
| 19 | 19 | $variation = wc_get_product($variation_id); |
| 20 | 20 | if (!$variation) continue; |
| 21 | - $basalam_id = get_post_meta($variation_id, 'sync_basalam_variation_id', true); | |
| 22 | - if (!$basalam_id) continue; | |
| 21 | + $basalam_ids = array_filter((array) get_post_meta($variation_id, 'sync_basalam_variation_id', false)); | |
| 22 | + if (!$basalam_ids) continue; | |
| 23 | 23 | |
| 24 | 24 | $regular = $variation->get_regular_price(); |
| 25 | 25 | $sale = $variation->get_sale_price(); |
| 26 | 26 | |
| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | |
| 27 | 27 | if (!$regular || !$sale) continue; |
| 28 | 28 | |
| 29 | 29 | $discount = $this->discountService->calculateDiscountPercent($regular, $sale); |
| 30 | - $this->discountService->apply($discount, null, [$basalam_id], null); | |
| 30 | + $this->discountService->apply($discount, null, $basalam_ids, null); | |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function remove($product): void |
| @@ -34,10 +34,9 @@ | ||
| 34 | 34 | public function remove($product): void |
| 35 | 35 | { |
| 36 | 36 | $basalam_ids = []; |
| 37 | 37 | foreach ($product->get_children() as $variation_id) { |
| 38 | - $basalam_id = get_post_meta($variation_id, 'sync_basalam_variation_id', true); | |
| 39 | - if ($basalam_id) $basalam_ids[] = $basalam_id; | |
| 38 | + $basalam_ids = array_merge($basalam_ids, array_filter((array) get_post_meta($variation_id, 'sync_basalam_variation_id', false))); | |
| 40 | 39 | } |
| 41 | 40 | if (!empty($basalam_ids)) $this->discountService->remove(null, $basalam_ids); |
| 42 | 41 | } |
| 43 | 42 | } |