PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.9.2
ووسلام – همگام سازی ووکامرس و باسلام v1.9.2
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 1.8.6 All 53 releases
sync-basalam / includes / Admin / Product / Data / Strategies / UpdateProductStrategy.php

UpdateProductStrategy.php in ووسلام – همگام سازی ووکامرس و باسلام 1.9.2, at includes/Admin/Product/Data/Strategies/UpdateProductStrategy.php

70 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SyncBasalam\Admin\Product\Data\Strategies;
4
5 use SyncBasalam\Admin\Product\Data\Handlers\ProductDataHandlerInterface;
6
7 defined('ABSPATH') || exit;
8
9 class UpdateProductStrategy implements DataStrategyInterface
10 {
11 public function collect($product, ProductDataHandlerInterface $handler): array
12 {
13 $data = apply_filters('sync_basalam_product_payload', null, $product, $handler, 'update');
14 if (!is_array($data)) {
15 $data = [];
16 }
17
18 if (!array_key_exists('name', $data)) {
19 $data['name'] = $handler->getName($product);
20 }
21 if (!array_key_exists('description', $data)) {
22 $data['description'] = $handler->getDescription($product);
23 }
24 if (!array_key_exists('weight', $data)) {
25 $data['weight'] = $handler->getWeight($product);
26 }
27 if (!array_key_exists('package_weight', $data)) {
28 $data['package_weight'] = $handler->getPackageWeight($product);
29 }
30 if (!array_key_exists('photo', $data)) {
31 $data['photo'] = $handler->getMainPhoto($product);
32 }
33 if (!array_key_exists('photos', $data)) {
34 $data['photos'] = $handler->getGalleryPhotos($product);
35 }
36 if (!array_key_exists('video', $data)) {
37 $video = $handler->getVideo($product);
38 if ($video !== null) {
39 $data['video'] = $video;
40 }
41 }
42 if (!array_key_exists('preparation_days', $data)) {
43 $data['preparation_days'] = $handler->getPreparationDays($product);
44 }
45 if (!array_key_exists('unit_type', $data)) {
46 $data['unit_type'] = $handler->getUnitType($product);
47 }
48 if (!array_key_exists('unit_quantity', $data)) {
49 $data['unit_quantity'] = $handler->getUnitQuantity($product);
50 }
51 if (!array_key_exists('is_wholesale', $data)) {
52 $data['is_wholesale'] = $handler->isWholesale($product);
53 }
54 if (!array_key_exists('variants', $data)) {
55 $data['variants'] = $handler->getVariants($product);
56 }
57
58 if (!$product->is_type('variable')) {
59 if (!array_key_exists('primary_price', $data)) {
60 $data['primary_price'] = $handler->getPrice($product);
61 }
62 if (!array_key_exists('stock', $data)) {
63 $data['stock'] = $handler->getStock($product);
64 }
65 }
66
67 return array_filter($data, fn($value) => $value !== null);
68 }
69 }
70