PluginProbe
Tiered Pricing Table for WooCommerce / 6.1.0
Tiered Pricing Table for WooCommerce v6.1.0
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 / LegacyHooks.php

LegacyHooks.php in Tiered Pricing Table for WooCommerce 6.1.0, at src/LegacyHooks.php

138 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable;
2
3 class LegacyHooks {
4
5 public function __construct() {
6
7 add_filter( 'tiered_pricing_table/price/pricing_rule', function ( PricingRule $pricingRule, $productId ) {
8 $hasDeprecated = false;
9
10 if ( has_action( 'tier_pricing_table/price/minimum' ) ) {
11 wc_deprecated_hook( 'tier_pricing_table/price/minimum', '3.0.0', 'tiered_pricing_table/price/pricing_rule' );
12 $hasDeprecated = true;
13 }
14
15 if ( has_action( 'tier_pricing_table/price/type' ) ) {
16 wc_deprecated_hook( 'tier_pricing_table/price/type', '3.0.0', 'tiered_pricing_table/price/pricing_rule' );
17 $hasDeprecated = true;
18 }
19
20 if ( has_action( 'tier_pricing_table/price/product_price_rules' ) ) {
21 wc_deprecated_hook( 'tier_pricing_table/price/product_price_rules', '3.0.0', 'tiered_pricing_table/price/pricing_rule' );
22 $hasDeprecated = true;
23 }
24
25 if ( ! $hasDeprecated ) {
26 return $pricingRule;
27 }
28
29 $rules = $pricingRule->getRules();
30 $pricingType = $pricingRule->getType();
31 $minimum = $pricingRule->getMinimum();
32
33 $minimum = apply_filters( 'tier_pricing_table/price/minimum', $minimum, $productId, $productId );
34 $pricingType = apply_filters( 'tier_pricing_table/price/type', $pricingType, $productId, 'view' );
35 $rules = apply_filters( 'tier_pricing_table/price/product_price_rules', $rules, $productId, $pricingType, $productId );
36
37 $pricingRule->setRules( $rules );
38 $pricingRule->setType( $pricingType );
39 $pricingRule->setMinimum( $minimum );
40
41 return $pricingRule;
42 }, 99, 2 );
43
44 add_filter( 'tiered_pricing_table/supported_simple_product_types', function ( $types ) {
45 if ( has_action( 'tier_pricing_table/supported_simple_product_types' ) ) {
46 wc_deprecated_hook( 'tier_pricing_table/supported_simple_product_types', '3.0.0', 'tiered_pricing_table/supported_simple_product_types' );
47 } else {
48 return $types;
49 }
50
51 $types = apply_filters( 'tier_pricing_table/supported_simple_product_types', $types );
52
53 return $types;
54 } );
55
56 add_filter( 'tiered_pricing_table/supported_variable_product_types', function ( $types ) {
57 if ( has_action( 'tier_pricing_table/supported_variable_product_types' ) ) {
58 wc_deprecated_hook( 'tier_pricing_table/supported_variable_product_types', '3.0.0', 'tiered_pricing_table/supported_variable_product_types' );
59 } else {
60 return $types;
61 }
62
63 $types = apply_filters( 'tier_pricing_table/supported_variable_product_types', $types );
64
65 return $types;
66 } );
67
68 add_filter( 'tiered_pricing_table/price/price_by_rules', function ( $productPrice, $quantity, $product_id, $context ) {
69 if ( has_action( 'tier_pricing_table/price/price_by_rules' ) ) {
70 wc_deprecated_hook( 'tier_pricing_table/price/price_by_rules', '3.0.0', 'tiered_pricing_table/price/price_by_rules' );
71 } else {
72 return $productPrice;
73 }
74
75 return apply_filters( 'tier_pricing_table/price/price_by_rules', $productPrice, $quantity, $product_id, $context );
76 }, 999, 5 );
77
78
79 add_filter( 'tiered_pricing_table/cart/need_price_recalculation', function ( $needRecalculation, $cartItem ) {
80 if ( has_action( 'tier_pricing_table/cart/need_price_recalculation' ) ) {
81 wc_deprecated_hook( 'tier_pricing_table/cart/need_price_recalculation', '3.0.0', 'tiered_pricing_table/cart/need_price_recalculation' );
82 } else {
83 return $needRecalculation;
84 }
85
86 /**
87 * Backwards compatibility
88 *
89 * @since 5.0.2
90 */
91 $needRecalculation = apply_filters( 'tier_pricing_table/cart/need_price_recalculation', $needRecalculation, $cartItem );
92
93 return $needRecalculation;
94 }, 999, 2 );
95
96 add_filter( 'tiered_pricing_table/cart/need_price_recalculation/item', function ( $needRecalculation, $cartItem ) {
97 if ( has_action( 'tier_pricing_table/cart/need_price_recalculation/item' ) ) {
98 wc_deprecated_hook( 'tier_pricing_table/cart/need_price_recalculation/item', '3.0.0', 'tiered_pricing_table/cart/need_price_recalculation/item' );
99 } else {
100 return $needRecalculation;
101 }
102
103 $needRecalculation = apply_filters( 'tier_pricing_table/cart/need_price_recalculation/item', $needRecalculation, $cartItem );
104
105 return $needRecalculation;
106 }, 999, 2 );
107
108 add_filter( 'tiered_pricing_table/cart/total_product_count', function ( $count, $cartItem ) {
109 if ( has_action( 'tier_pricing_table/cart/total_product_count' ) ) {
110 wc_deprecated_hook( 'tier_pricing_table/cart/total_product_count', '3.0.0', 'tiered_pricing_table/cart/total_product_count' );
111 } else {
112 return $count;
113 }
114
115 return apply_filters( 'tier_pricing_table/cart/total_product_count', $count, $cartItem );
116 }, 999, 2 );
117
118 add_filter( 'tiered_pricing_table/cart/product_cart_price', function ( $new_price, $cartItem, $key ) {
119 if ( has_action( 'tier_pricing_table/cart/product_cart_price' ) ) {
120 wc_deprecated_hook( 'tier_pricing_table/cart/product_cart_price', '3.0.0', 'tiered_pricing_table/cart/product_cart_price' );
121 } else {
122 return $new_price;
123 }
124
125 return apply_filters( 'tier_pricing_table/cart/product_cart_price', $new_price, $cartItem, $key );
126 }, 999, 3 );
127
128 add_filter( 'tiered_pricing_table/cart/product_cart_price/item', function ( $new_price, $cartItem ) {
129 if ( has_action( 'tier_pricing_table/cart/product_cart_price/item' ) ) {
130 wc_deprecated_hook( 'tier_pricing_table/cart/product_cart_price/item', '3.0.0', 'tiered_pricing_table/cart/product_cart_price/item' );
131 } else {
132 return $new_price;
133 }
134
135 return apply_filters( 'tier_pricing_table/cart/product_cart_price/item', $new_price, $cartItem );
136 }, 999, 2 );
137 }
138 }