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 / Services / LegacyHooksService.php

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

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