PluginProbe
Tiered Pricing Table for WooCommerce / 2.3.0
Tiered Pricing Table for WooCommerce v2.3.0
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 2.3.4 All 90 releases
← All changes | src/PriceManager.php +27 -4 2.02.3.0 View file →
@@ -47,9 +47,14 @@
47 47 }
48 48
49 49 $rules = ( !empty($rules) ? $rules : [] );
50 50 ksort( $rules );
51 - return $rules;
51 + return apply_filters(
52 + 'tier_pricing_table/price/product_price_rules',
53 + $rules,
54 + $product_id,
55 + $type
56 + );
52 57 }
53 58
54 59 /**
55 60 * Get price by product quantity
@@ -64,11 +69,17 @@
64 69 $rules = self::getPriceRules( $product_id );
65 70 $type = self::getPricingType( $product_id );
66 71 if ( $type === 'fixed' ) {
67 72 foreach ( array_reverse( $rules, true ) as $_amount => $price ) {
73 +
68 74 if ( $_amount <= $quantity ) {
69 - return $price;
75 + $product_price = wc_get_price_to_display( wc_get_product( $product_id ), [
76 + 'price' => $price,
77 + 'qty' => 1,
78 + ] );
79 + break;
70 80 }
81 +
71 82 }
72 83 }
73 84
74 85 if ( $type === 'percentage' ) {
@@ -73,15 +84,27 @@
73 84
74 85 if ( $type === 'percentage' ) {
75 86 $product = wc_get_product( $product_id );
76 87 foreach ( array_reverse( $rules, true ) as $_amount => $percentDiscount ) {
88 +
77 89 if ( $_amount <= $quantity ) {
78 - return self::getPriceByPercentDiscount( $product->get_price(), $percentDiscount );
90 + $product_price = wc_get_price_to_display( $product, [
91 + 'price' => self::getPriceByPercentDiscount( $product->get_price(), $percentDiscount ),
92 + 'qty' => 1,
93 + ] );
94 + break;
79 95 }
96 +
80 97 }
81 98 }
82 99
83 - return false;
100 + $product_price = ( isset( $product_price ) ? $product_price : false );
101 + return apply_filters(
102 + 'tier_pricing_table/price/price_by_rules',
103 + $product_price,
104 + $quantity,
105 + $product_id
106 + );
84 107 }
85 108
86 109 /**
87 110 * Calculate price using percentage discount