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.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / legacy / class-wc-legacy-coupon.php
woocommerce / includes / legacy Last commit date
api 5 years ago abstract-wc-legacy-order.php 5 years ago abstract-wc-legacy-payment-token.php 5 years ago abstract-wc-legacy-product.php 5 years ago class-wc-legacy-api.php 5 years ago class-wc-legacy-cart.php 5 years ago class-wc-legacy-coupon.php 5 years ago class-wc-legacy-customer.php 5 years ago class-wc-legacy-shipping-zone.php 5 years ago class-wc-legacy-webhook.php 5 years ago
class-wc-legacy-coupon.php
205 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5
6 /**
7 * Legacy Coupon.
8 *
9 * Legacy and deprecated functions are here to keep the WC_Legacy_Coupon class clean.
10 * This class will be removed in future versions.
11 *
12 * @class WC_Legacy_Coupon
13 * @version 3.0.0
14 * @package WooCommerce\Classes
15 * @category Class
16 * @author WooThemes
17 */
18 abstract class WC_Legacy_Coupon extends WC_Data {
19
20 /**
21 * Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past.
22 * @param string $key
23 * @return bool
24 */
25 public function __isset( $key ) {
26 $legacy_keys = array(
27 'id',
28 'exists',
29 'coupon_custom_fields',
30 'type',
31 'discount_type',
32 'amount',
33 'coupon_amount',
34 'code',
35 'individual_use',
36 'product_ids',
37 'exclude_product_ids',
38 'usage_limit',
39 'usage_limit_per_user',
40 'limit_usage_to_x_items',
41 'usage_count',
42 'expiry_date',
43 'product_categories',
44 'exclude_product_categories',
45 'minimum_amount',
46 'maximum_amount',
47 'customer_email',
48 );
49 if ( in_array( $key, $legacy_keys ) ) {
50 return true;
51 }
52 return false;
53 }
54
55 /**
56 * Magic __get method for backwards compatibility. Maps legacy vars to new getters.
57 * @param string $key
58 * @return mixed
59 */
60 public function __get( $key ) {
61 wc_doing_it_wrong( $key, 'Coupon properties should not be accessed directly.', '3.0' );
62
63 switch ( $key ) {
64 case 'id' :
65 $value = $this->get_id();
66 break;
67 case 'exists' :
68 $value = $this->get_id() > 0;
69 break;
70 case 'coupon_custom_fields' :
71 $legacy_custom_fields = array();
72 $custom_fields = $this->get_id() ? $this->get_meta_data() : array();
73 if ( ! empty( $custom_fields ) ) {
74 foreach ( $custom_fields as $cf_value ) {
75 // legacy only supports 1 key
76 $legacy_custom_fields[ $cf_value->key ][0] = $cf_value->value;
77 }
78 }
79 $value = $legacy_custom_fields;
80 break;
81 case 'type' :
82 case 'discount_type' :
83 $value = $this->get_discount_type();
84 break;
85 case 'amount' :
86 case 'coupon_amount' :
87 $value = $this->get_amount();
88 break;
89 case 'code' :
90 $value = $this->get_code();
91 break;
92 case 'individual_use' :
93 $value = ( true === $this->get_individual_use() ) ? 'yes' : 'no';
94 break;
95 case 'product_ids' :
96 $value = $this->get_product_ids();
97 break;
98 case 'exclude_product_ids' :
99 $value = $this->get_excluded_product_ids();
100 break;
101 case 'usage_limit' :
102 $value = $this->get_usage_limit();
103 break;
104 case 'usage_limit_per_user' :
105 $value = $this->get_usage_limit_per_user();
106 break;
107 case 'limit_usage_to_x_items' :
108 $value = $this->get_limit_usage_to_x_items();
109 break;
110 case 'usage_count' :
111 $value = $this->get_usage_count();
112 break;
113 case 'expiry_date' :
114 $value = ( $this->get_date_expires() ? $this->get_date_expires()->date( 'Y-m-d' ) : '' );
115 break;
116 case 'product_categories' :
117 $value = $this->get_product_categories();
118 break;
119 case 'exclude_product_categories' :
120 $value = $this->get_excluded_product_categories();
121 break;
122 case 'minimum_amount' :
123 $value = $this->get_minimum_amount();
124 break;
125 case 'maximum_amount' :
126 $value = $this->get_maximum_amount();
127 break;
128 case 'customer_email' :
129 $value = $this->get_email_restrictions();
130 break;
131 default :
132 $value = '';
133 break;
134 }
135
136 return $value;
137 }
138
139 /**
140 * Format loaded data as array.
141 * @param string|array $array
142 * @return array
143 */
144 public function format_array( $array ) {
145 wc_deprecated_function( 'WC_Coupon::format_array', '3.0' );
146 if ( ! is_array( $array ) ) {
147 if ( is_serialized( $array ) ) {
148 $array = maybe_unserialize( $array );
149 } else {
150 $array = explode( ',', $array );
151 }
152 }
153 return array_filter( array_map( 'trim', array_map( 'strtolower', $array ) ) );
154 }
155
156
157 /**
158 * Check if coupon needs applying before tax.
159 *
160 * @return bool
161 */
162 public function apply_before_tax() {
163 wc_deprecated_function( 'WC_Coupon::apply_before_tax', '3.0' );
164 return true;
165 }
166
167 /**
168 * Check if a coupon enables free shipping.
169 *
170 * @return bool
171 */
172 public function enable_free_shipping() {
173 wc_deprecated_function( 'WC_Coupon::enable_free_shipping', '3.0', 'WC_Coupon::get_free_shipping' );
174 return $this->get_free_shipping();
175 }
176
177 /**
178 * Check if a coupon excludes sale items.
179 *
180 * @return bool
181 */
182 public function exclude_sale_items() {
183 wc_deprecated_function( 'WC_Coupon::exclude_sale_items', '3.0', 'WC_Coupon::get_exclude_sale_items' );
184 return $this->get_exclude_sale_items();
185 }
186
187 /**
188 * Increase usage count for current coupon.
189 *
190 * @param string $used_by Either user ID or billing email
191 */
192 public function inc_usage_count( $used_by = '' ) {
193 $this->increase_usage_count( $used_by );
194 }
195
196 /**
197 * Decrease usage count for current coupon.
198 *
199 * @param string $used_by Either user ID or billing email
200 */
201 public function dcr_usage_count( $used_by = '' ) {
202 $this->decrease_usage_count( $used_by );
203 }
204 }
205