← All changes
|
includes/Admin/Product/Data/Services/AttributeService.php
+14
-0
1.8.8
→
1.10.19
View file →
| @@ -10,12 +10,14 @@ | ||
| 10 | 10 | |
| 11 | 11 | class AttributeService |
| 12 | 12 | { |
| 13 | 13 | private $mobileDataHandler; |
| 14 | + private $goldDataHandler; | |
| 14 | 15 | |
| 15 | 16 | public function __construct() |
| 16 | 17 | { |
| 17 | 18 | $this->mobileDataHandler = new MobileDataHandler(); |
| 19 | + $this->goldDataHandler = new GoldDataHandler(); | |
| 18 | 20 | } |
| 19 | 21 | |
| 20 | 22 | public function getAttributeSuffix($product): ?string |
| 21 | 23 | { |
| @@ -75,8 +77,10 @@ | ||
| 75 | 77 | $attributes = []; |
| 76 | 78 | |
| 77 | 79 | if ($this->isMobileProduct($product)) $attributes = array_merge($attributes, $this->getMobileAttributes($product)); |
| 78 | 80 | |
| 81 | + if ($this->isGoldProduct($product)) $attributes = array_merge($attributes, $this->getGoldAttributes($product)); | |
| 82 | + | |
| 79 | 83 | $wooAttributes = $this->getMappedAttributes($product); |
| 80 | 84 | if (!empty($wooAttributes)) $attributes = array_merge($attributes, $wooAttributes); |
| 81 | 85 | |
| 82 | 86 | return $attributes; |
| @@ -175,8 +179,13 @@ | ||
| 175 | 179 | { |
| 176 | 180 | return $this->mobileDataHandler->getMobileAttributesAsArray($product); |
| 177 | 181 | } |
| 178 | 182 | |
| 183 | + private function getGoldAttributes($product): array | |
| 184 | + { | |
| 185 | + return $this->goldDataHandler->getGoldAttributesAsArray($product); | |
| 186 | + } | |
| 187 | + | |
| 179 | 188 | private function getMappedCategoryOptions(): array |
| 180 | 189 | { |
| 181 | 190 | global $wpdb; |
| 182 | 191 | $categoryOptionsManager = new \SyncBasalam\Admin\Product\Category\CategoryOptions($wpdb); |
| @@ -185,6 +194,11 @@ | ||
| 185 | 194 | |
| 186 | 195 | private function isMobileProduct($product): bool |
| 187 | 196 | { |
| 188 | 197 | return get_post_meta($product->get_id(), '_sync_basalam_is_mobile_product_checkbox', true) === 'yes'; |
| 198 | + } | |
| 199 | + | |
| 200 | + private function isGoldProduct($product): bool | |
| 201 | + { | |
| 202 | + return get_post_meta($product->get_id(), '_sync_basalam_is_gold_product_checkbox', true) === 'yes'; | |
| 189 | 203 | } |
| 190 | 204 | } |