| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentCart\App\Http\Requests; |
| 4 | 4 | |
| 5 | +use FluentCart\App\Helpers\Helper; | |
| 5 | 6 | use FluentCart\App\Models\ShippingClass; |
| 6 | 7 | use FluentCart\App\Services\DateTime\DateTime; |
| 7 | 8 | use FluentCart\Framework\Foundation\RequestGuard; |
| 8 | 9 | use FluentCart\Framework\Support\Arr; |
| @@ -40,8 +41,14 @@ | ||
| 40 | 41 | return __('Invalid fulfillment type.', 'fluent-cart'); |
| 41 | 42 | } |
| 42 | 43 | return null; |
| 43 | 44 | }], |
| 45 | + 'detail.variation_type' => ['sanitizeText', function ($attribute, $value) { | |
| 46 | + if ($value !== null && $value !== '' && !in_array($value, Helper::getVariationTypes(false), true)) { | |
| 47 | + return __('Invalid variation type.', 'fluent-cart'); | |
| 48 | + } | |
| 49 | + return null; | |
| 50 | + }], | |
| 44 | 51 | ]; |
| 45 | 52 | } |
| 46 | 53 | |
| 47 | 54 | |
| @@ -71,8 +78,12 @@ | ||
| 71 | 78 | if (empty($value)) { |
| 72 | 79 | return 'digital'; |
| 73 | 80 | } |
| 74 | 81 | return sanitize_text_field($value); |
| 82 | + }, | |
| 83 | + | |
| 84 | + 'detail.variation_type' => function ($value) { | |
| 85 | + return in_array($value, Helper::getVariationTypes(false), true) ? $value : 'simple'; | |
| 75 | 86 | }, |
| 76 | 87 | |
| 77 | 88 | 'detail.other_info.is_bundle_product' => function ($value) { |
| 78 | 89 | return $value === 'yes' ? 'yes' : 'no'; |