PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.19
ووسلام – همگام سازی ووکامرس و باسلام v1.10.19
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 / Validators / WeightValidator.php

WeightValidator.php in ووسلام – همگام سازی ووکامرس و باسلام 1.10.19, at includes/Admin/Product/Data/Validators/WeightValidator.php

27 lines 651 B
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\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