PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.21
ووسلام – همگام سازی ووکامرس و باسلام v1.10.21
1.10.21 1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 All 54 releases
← All changes | includes/Admin/Product/Data/Handlers/SimpleProductHandler.php +13 -1 1.8.81.10.21 View file →
@@ -7,8 +7,9 @@
7 7 use SyncBasalam\Admin\Product\Data\Services\PhotoService;
8 8 use SyncBasalam\Admin\Product\Data\Services\VideoService;
9 9 use SyncBasalam\Admin\Product\Data\Services\AttributeService;
10 10 use SyncBasalam\Admin\Settings\SettingsConfig;
11 +use SyncBasalam\Services\Products\PreparationDaysGuard;
11 12
12 13 defined('ABSPATH') || exit;
13 14
14 15 class SimpleProductHandler implements ProductDataHandlerInterface
@@ -17,8 +18,9 @@
17 18 private $priceService;
18 19 private $photoService;
19 20 private $videoService;
20 21 private $attributeService;
22 + private $preparationGuard;
21 23 private array $settings;
22 24
23 25 public function __construct()
24 26 {
@@ -26,8 +28,9 @@
26 28 $this->priceService = new PriceService();
27 29 $this->photoService = new PhotoService();
28 30 $this->videoService = new VideoService();
29 31 $this->attributeService = new AttributeService();
32 + $this->preparationGuard = new PreparationDaysGuard();
30 33 $this->settings = syncBasalamSettings()->getSettings();
31 34 }
32 35
33 36 public function getName($product): string
@@ -45,8 +48,15 @@
45 48
46 49 return mb_substr($name, 0, 120);
47 50 }
48 51
52 + public function getSku($product): ?string
53 + {
54 + $sku = trim((string) $product->get_sku());
55 +
56 + return $sku !== '' ? $sku : null;
57 + }
58 +
49 59 public function getDescription($product): string
50 60 {
51 61 return $this->attributeService->generateDescription($product);
52 62 }
@@ -114,9 +124,11 @@
114 124 }
115 125
116 126 public function getPreparationDays($product): int
117 127 {
118 - return $this->settings[SettingsConfig::DEFAULT_PREPARATION];
128 + $preparationDays = (int) $this->settings[SettingsConfig::DEFAULT_PREPARATION];
129 +
130 + return $this->preparationGuard->enforce($preparationDays, $product);
119 131 }
120 132
121 133 public function getUnitType($product): int
122 134 {