| 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     2.7.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 |  |  | 			'code', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 			'individual_use', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 			'product_ids', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 			'exclude_product_ids', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 			'usage_limit', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 			'usage_limit_per_user', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 			'limit_usage_to_x_items', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 			'usage_count', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 			'expiry_date', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 			'product_categories', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 			'exclude_product_categories', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 			'minimum_amount', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 			'maximum_amount', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 			'customer_email', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		if ( in_array( $key, $legacy_keys ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 			return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	 * Magic __get method for backwards compatibility. Maps legacy vars to new getters. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 	 * @param  string $key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	 * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	public function __get( $key ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 		_doing_it_wrong( $key, 'Coupon properties should not be accessed directly.', '2.7' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		switch ( $key ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 			case 'id' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 				$value = $this->get_id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 			case 'exists' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 				$value = ( $this->get_id() > 0 ) ? true : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 			case 'coupon_custom_fields' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 				$legacy_custom_fields = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 				$custom_fields = $this->get_id() ? $this->get_meta_data() : array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 				if ( ! empty( $custom_fields ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 					foreach ( $custom_fields as  $cf_value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 						// legacy only supports 1 key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 						$legacy_custom_fields[ $cf_value->key ][0] = $cf_value->value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 				$value = $legacy_custom_fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 			case 'type' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 			case 'discount_type' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 				$value = $this->get_discount_type(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 			case 'amount' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 				$value = $this->get_amount(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 			case 'code' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 				$value = $this->get_code(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 			case 'individual_use' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 				$value = ( true === $this->get_individual_use() ) ? 'yes' : 'no'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 			case 'product_ids' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 				$value = $this->get_product_ids(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 			case 'exclude_product_ids' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 				$value = $this->get_excluded_product_ids(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 			case 'usage_limit' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 				$value = $this->get_usage_limit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 			case 'usage_limit_per_user' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 				$value = $this->get_usage_limit_per_user(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 			case 'limit_usage_to_x_items' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 				$value = $this->get_limit_usage_to_x_items(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 			case 'usage_count' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 				$value = $this->get_usage_count(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 			case 'expiry_date' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 				$value = $this->get_expiry_date(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 			case 'product_categories' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 				$value = $this->get_product_categories(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 			case 'exclude_product_categories' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 				$value = $this->get_excluded_product_categories(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			case 'minimum_amount' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 				$value = $this->get_minimum_amount(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 			case 'maximum_amount' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 				$value = $this->get_maximum_amount(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 			case 'customer_email' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 				$value = $this->get_email_restrictions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 			default : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 				$value = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 			break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 		return $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 	 * Format loaded data as array. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	 * @param  string|array $array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 	public function format_array( $array ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 		_deprecated_function( 'format_array', '2.7', '' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 		if ( ! is_array( $array ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 			if ( is_serialized( $array ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 				$array = maybe_unserialize( $array ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 				$array = explode( ',', $array ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 		return array_filter( array_map( 'trim', array_map( 'strtolower', $array ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 	 * Check if coupon needs applying before tax. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 	 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 	public function apply_before_tax() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 		_deprecated_function( 'apply_before_tax', '2.7', '' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 		return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 	 * Check if a coupon enables free shipping. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 	 * @return bool | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 169 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  | 	public function enable_free_shipping() { | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  | 		_deprecated_function( 'enable_free_shipping', '2.7', 'get_free_shipping' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  | 		return $this->get_free_shipping(); | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 	 * Check if a coupon excludes sale items. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 	 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 	public function exclude_sale_items() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 		_deprecated_function( 'exclude_sale_items', '2.7', 'get_exclude_sale_items' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 		return $this->get_exclude_sale_items(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 184 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 185 |  |  |  | 
            
                        
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.