| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Admin\Product\Data\Validators; |
| 4 |
|
| 5 |
defined('ABSPATH') || exit; |
| 6 |
|
| 7 |
class WeightValidator implements ValidatorInterface |
| 8 |
{ |
| 9 |
public function validate($product): void |
| 10 |
{ |
| 11 |
$rawWeight = $product->get_weight(); |
| 12 |
|
| 13 |
if (empty($rawWeight)) return; |
| 14 |
|
| 15 |
$weight = floatval(str_replace(',', '.', $rawWeight)); |
| 16 |
$weightUnit = get_option('woocommerce_weight_unit'); |
| 17 |
|
| 18 |
$weightInGrams = ($weightUnit === 'kg') ? $weight * 1000 : $weight; |
| 19 |
|
| 20 |
if ($weightInGrams < 0.001) throw new \InvalidArgumentException('وزن � |
| 21 |
حصول نباید ک� |
| 22 |
تر از یک هزار� |
| 23 |
گر� |
| 24 |
باشد.'); |
| 25 |
} |
| 26 |
} |
| 27 |
|