| 1 |
<?php namespace TierPricingTable\Addons\AdvancedQuantityOptions\API; |
| 2 |
|
| 3 |
use TierPricingTable\Addons\AdvancedQuantityOptions\DataProvider; |
| 4 |
use TierPricingTable\Services\API\ProductFields\ProductField; |
| 5 |
use WC_Product; |
| 6 |
|
| 7 |
class MaximumOrderQuantity extends ProductField { |
| 8 |
|
| 9 |
public function getFieldSlug(): string { |
| 10 |
return 'tiered_pricing_maximum_quantity'; |
| 11 |
} |
| 12 |
|
| 13 |
public function getValue( array $product ) { |
| 14 |
return DataProvider::getMaximumQuantity( $product['id'], null, 'edit' ); |
| 15 |
} |
| 16 |
|
| 17 |
public function updateValue( $value, WC_Product $product ) { |
| 18 |
$value = empty( $value ) ? null : (int) $value; |
| 19 |
|
| 20 |
DataProvider::updateMaximumQuantity( $product->get_id(), $value ); |
| 21 |
} |
| 22 |
|
| 23 |
public function getType(): string { |
| 24 |
return 'string'; |
| 25 |
} |
| 26 |
|
| 27 |
public function getDescription(): string { |
| 28 |
return 'Maximum order quantity.'; |
| 29 |
} |
| 30 |
} |
| 31 |
|