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 / Services / GoldDataHandler.php

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

60 lines 1.4 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\Services;
4
5 defined('ABSPATH') || exit;
6
7 class GoldDataHandler
8 {
9 public static function getGoldAttributesAsArray($product): array
10 {
11 $goldData = self::getGoldData($product);
12
13 return [
14 [
15 'attribute_id' => 1785,
16 'value' => $goldData['purity'] ?? '',
17 ],
18 [
19 'attribute_id' => 1786,
20 'value' => $goldData['weight'] ?? '',
21 ],
22 ];
23 }
24
25 public static function getGoldData($product): array
26 {
27 return [
28 'purity' => get_post_meta($product->get_id(), '_sync_basalam_gold_purity', true),
29 'weight' => get_post_meta($product->get_id(), '_sync_basalam_gold_weight', true),
30 ];
31 }
32
33 public static function hasGoldData($product): bool
34 {
35 $fields = [
36 '_sync_basalam_gold_purity',
37 '_sync_basalam_gold_weight',
38 ];
39
40 foreach ($fields as $field) {
41 if (!empty(get_post_meta($product->get_id(), $field, true))) {
42 return true;
43 }
44 }
45
46 return false;
47 }
48
49 public static function getAllGoldFields(): array
50 {
51 return [
52 'purity' => 'عیار طلا (�
53 بنای 1000)',
54 'weight' => 'وزن طلا (�
55 یلی گر�
56 )',
57 ];
58 }
59 }
60