PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
tier-pricing-table / src / Services / API / ProductFields / FixedTieredPricing.php

FixedTieredPricing.php in Tiered Pricing Table for WooCommerce 8.0.2, at src/Services/API/ProductFields/FixedTieredPricing.php

39 lines 989 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Services\API\ProductFields;
2
3 use TierPricingTable\PriceManager;
4 use WC_Product;
5
6 class FixedTieredPricing extends ProductField {
7
8 public function getFieldSlug(): string {
9 return 'tiered_pricing_fixed_rules';
10 }
11
12 public function sanitizeValue( $value ): array {
13 $rules = array();
14 $value = is_array( $value ) ? $value : array();
15
16 foreach ( $value as $key => $val ) {
17 $rules[ (int) $key ] = (float) $val;
18 }
19
20 return $rules;
21 }
22
23 public function getValue( array $product ): array {
24 return PriceManager::getFixedPriceRules( (int) $product['id'], 'edit' );
25 }
26
27 public function updateValue( $value, WC_Product $product ) {
28 update_post_meta( $product->get_id(), '_fixed_price_rules', $this->sanitizeValue( $value ) );
29 }
30
31 public function getType(): string {
32 return 'object';
33 }
34
35 public function getDescription(): string {
36 return 'Tiered pricing fixed rules. Key is a quantity and value is a price. Minimum quantity is 2';
37 }
38 }
39