PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.27
ووسلام – همگام سازی ووکامرس و باسلام v1.10.27
1.1.26 1.10.27 1.10.24 1.10.25 1.10.23 1.10.22 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 All 60 releases
← All changes | includes/Admin/Product/Data/Services/AttributeService.php +17 -5 1.10.17 → 1.10.27 View file →
@@ -24,19 +24,31 @@
24 24 $isEnabled = syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_ENABLED);
25 25
26 26 if ($isEnabled !== 'yes') return null;
27 27
28 - $attributeName = trim(syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_PRIORITY));
28 + $configuredNames = (string) syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_PRIORITY);
29 + $attributeNames = array_unique(array_filter(
30 + array_map('trim', preg_split('/[,،]/u', $configuredNames)),
31 + static function ($name) { return $name !== ''; }
32 + ));
29 33
30 - if (empty($attributeName)) return null;
34 + if (empty($attributeNames)) return null;
31 35
32 36 $wooAttributes = $this->getWooCommerceAttributes($product);
37 + $suffixValues = [];
33 38
34 - foreach ($wooAttributes as $attribute) {
35 - if (trim($attribute['title']) === $attributeName && !empty($attribute['value'])) return $attribute['value'];
39 + // Follow the configured order, regardless of the product's attribute order.
40 + foreach ($attributeNames as $attributeName) {
41 + foreach ($wooAttributes as $attribute) {
42 + $value = trim($attribute['value']);
43 + if (trim($attribute['title']) === $attributeName && $value !== '') {
44 + $suffixValues[] = $value;
45 + break;
46 + }
47 + }
36 48 }
37 49
38 - return null;
50 + return empty($suffixValues) ? null : implode(', ', $suffixValues);
39 51 }
40 52
41 53 public function generateDescription($product): string
42 54 {