# sync-basalam/1.10.2/includes/Admin/Product/Data/Services/GoldDataHandler.php

ووسلام – همگام سازی ووکامرس و باسلام, version 1.10.2. 57 lines.

- Page: https://pluginprobe.com/plugins/sync-basalam/1.10.2/code/includes/Admin/Product/Data/Services/GoldDataHandler.php
- Raw: https://pluginprobe.com/plugins/sync-basalam/1.10.2/raw/includes/Admin/Product/Data/Services/GoldDataHandler.php
- Modified: 2026-07-19T10:26:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/sync-basalam/1.10.2/code/includes/Admin/Product/Data/Services/GoldDataHandler.php#L10-L20`.

```php
<?php

namespace SyncBasalam\Admin\Product\Data\Services;

defined('ABSPATH') || exit;

class GoldDataHandler
{
    public static function getGoldAttributesAsArray($product): array
    {
        $goldData = self::getGoldData($product);

        return [
            [
                'attribute_id' => 1785,
                'value' => $goldData['purity'] ?? '',
            ],
            [
                'attribute_id' => 1786,
                'value' => $goldData['weight'] ?? '',
            ],
        ];
    }

    public static function getGoldData($product): array
    {
        return [
            'purity' => get_post_meta($product->get_id(), '_sync_basalam_gold_purity', true),
            'weight' => get_post_meta($product->get_id(), '_sync_basalam_gold_weight', true),
        ];
    }

    public static function hasGoldData($product): bool
    {
        $fields = [
            '_sync_basalam_gold_purity',
            '_sync_basalam_gold_weight',
        ];

        foreach ($fields as $field) {
            if (!empty(get_post_meta($product->get_id(), $field, true))) {
                return true;
            }
        }

        return false;
    }

    public static function getAllGoldFields(): array
    {
        return [
            'purity' => 'عیار طلا (مبنای 1000)',
            'weight' => 'وزن طلا (میلی گرم)',
        ];
    }
}

```
