@@ -8,77 +8,77 @@ |
||
| 8 | 8 | |
| 9 | 9 | class Shipping_Zones { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @var Shipping_Zone[] |
|
| 13 | - */ |
|
| 14 | - private $zones; |
|
| 11 | + /** |
|
| 12 | + * @var Shipping_Zone[] |
|
| 13 | + */ |
|
| 14 | + private $zones; |
|
| 15 | 15 | |
| 16 | - public function __construct() { |
|
| 17 | - $this->zones = array(); |
|
| 18 | - } |
|
| 16 | + public function __construct() { |
|
| 17 | + $this->zones = array(); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - private function load_zones() { |
|
| 20 | + private function load_zones() { |
|
| 21 | 21 | |
| 22 | - $zone_ids = array_keys( WC_Shipping_Zones::get_zones() ); |
|
| 23 | - $wc_shipping_zones = array( WC_Shipping_Zones::get_zone( 0 ) ); |
|
| 24 | - foreach ( $zone_ids as $zone_id ) { |
|
| 25 | - $wc_shipping_zones[] = WC_Shipping_Zones::get_zone( $zone_id ); |
|
| 26 | - } |
|
| 22 | + $zone_ids = array_keys( WC_Shipping_Zones::get_zones() ); |
|
| 23 | + $wc_shipping_zones = array( WC_Shipping_Zones::get_zone( 0 ) ); |
|
| 24 | + foreach ( $zone_ids as $zone_id ) { |
|
| 25 | + $wc_shipping_zones[] = WC_Shipping_Zones::get_zone( $zone_id ); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - $zones = array(); |
|
| 29 | - foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 30 | - $country_codes = $this->get_country_codes( $wc_shipping_zone->get_zone_locations() ); |
|
| 28 | + $zones = array(); |
|
| 29 | + foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 30 | + $country_codes = $this->get_country_codes( $wc_shipping_zone->get_zone_locations() ); |
|
| 31 | 31 | |
| 32 | - if ( empty( $country_codes ) ) { |
|
| 33 | - $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone ); |
|
| 34 | - } else { |
|
| 35 | - foreach ( $country_codes as $country_code ) { |
|
| 36 | - $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone, $country_code ); |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - } |
|
| 32 | + if ( empty( $country_codes ) ) { |
|
| 33 | + $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone ); |
|
| 34 | + } else { |
|
| 35 | + foreach ( $country_codes as $country_code ) { |
|
| 36 | + $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone, $country_code ); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $this->zones = $zones; |
|
| 41 | + $this->zones = $zones; |
|
| 42 | 42 | |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 45 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 46 | 46 | |
| 47 | - $this->load_zones(); |
|
| 47 | + $this->load_zones(); |
|
| 48 | 48 | |
| 49 | - foreach ( $this->zones as $zone ) { |
|
| 50 | - $zone->add_available_delivery_method( $jsonld ); |
|
| 51 | - } |
|
| 49 | + foreach ( $this->zones as $zone ) { |
|
| 50 | + $zone->add_available_delivery_method( $jsonld ); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function add_offer_shipping_details( &$jsonld ) { |
|
| 55 | + public function add_offer_shipping_details( &$jsonld ) { |
|
| 56 | 56 | |
| 57 | - $this->load_zones(); |
|
| 57 | + $this->load_zones(); |
|
| 58 | 58 | |
| 59 | - foreach ( $this->zones as $zone ) { |
|
| 60 | - $zone->add_offer_shipping_details( $jsonld ); |
|
| 61 | - } |
|
| 59 | + foreach ( $this->zones as $zone ) { |
|
| 60 | + $zone->add_offer_shipping_details( $jsonld ); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - private function get_country_codes( $wc_shipping_zones ) { |
|
| 66 | - $countries = array(); |
|
| 65 | + private function get_country_codes( $wc_shipping_zones ) { |
|
| 66 | + $countries = array(); |
|
| 67 | 67 | |
| 68 | - foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 69 | - if ( ! isset( $wc_shipping_zone->type ) |
|
| 70 | - || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) { |
|
| 71 | - continue; |
|
| 72 | - } |
|
| 68 | + foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 69 | + if ( ! isset( $wc_shipping_zone->type ) |
|
| 70 | + || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) { |
|
| 71 | + continue; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $country = substr( $wc_shipping_zone->code, 0, 2 ); |
|
| 74 | + $country = substr( $wc_shipping_zone->code, 0, 2 ); |
|
| 75 | 75 | |
| 76 | - if ( ! in_array( $country, $countries ) ) { |
|
| 77 | - $countries[] = $country; |
|
| 78 | - } |
|
| 79 | - } |
|
| 76 | + if ( ! in_array( $country, $countries ) ) { |
|
| 77 | + $countries[] = $country; |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - return $countries; |
|
| 82 | - } |
|
| 81 | + return $countries; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | } |
@@ -19,21 +19,21 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | private function load_zones() { |
| 21 | 21 | |
| 22 | - $zone_ids = array_keys( WC_Shipping_Zones::get_zones() ); |
|
| 23 | - $wc_shipping_zones = array( WC_Shipping_Zones::get_zone( 0 ) ); |
|
| 24 | - foreach ( $zone_ids as $zone_id ) { |
|
| 25 | - $wc_shipping_zones[] = WC_Shipping_Zones::get_zone( $zone_id ); |
|
| 22 | + $zone_ids = array_keys(WC_Shipping_Zones::get_zones()); |
|
| 23 | + $wc_shipping_zones = array(WC_Shipping_Zones::get_zone(0)); |
|
| 24 | + foreach ($zone_ids as $zone_id) { |
|
| 25 | + $wc_shipping_zones[] = WC_Shipping_Zones::get_zone($zone_id); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | $zones = array(); |
| 29 | - foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 30 | - $country_codes = $this->get_country_codes( $wc_shipping_zone->get_zone_locations() ); |
|
| 29 | + foreach ($wc_shipping_zones as $wc_shipping_zone) { |
|
| 30 | + $country_codes = $this->get_country_codes($wc_shipping_zone->get_zone_locations()); |
|
| 31 | 31 | |
| 32 | - if ( empty( $country_codes ) ) { |
|
| 33 | - $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone ); |
|
| 32 | + if (empty($country_codes)) { |
|
| 33 | + $zones[] = Shipping_Zone::from_wc_shipping_zone($wc_shipping_zone); |
|
| 34 | 34 | } else { |
| 35 | - foreach ( $country_codes as $country_code ) { |
|
| 36 | - $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone, $country_code ); |
|
| 35 | + foreach ($country_codes as $country_code) { |
|
| 36 | + $zones[] = Shipping_Zone::from_wc_shipping_zone($wc_shipping_zone, $country_code); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -42,38 +42,38 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 45 | + public function add_available_delivery_method(&$jsonld) { |
|
| 46 | 46 | |
| 47 | 47 | $this->load_zones(); |
| 48 | 48 | |
| 49 | - foreach ( $this->zones as $zone ) { |
|
| 50 | - $zone->add_available_delivery_method( $jsonld ); |
|
| 49 | + foreach ($this->zones as $zone) { |
|
| 50 | + $zone->add_available_delivery_method($jsonld); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function add_offer_shipping_details( &$jsonld ) { |
|
| 55 | + public function add_offer_shipping_details(&$jsonld) { |
|
| 56 | 56 | |
| 57 | 57 | $this->load_zones(); |
| 58 | 58 | |
| 59 | - foreach ( $this->zones as $zone ) { |
|
| 60 | - $zone->add_offer_shipping_details( $jsonld ); |
|
| 59 | + foreach ($this->zones as $zone) { |
|
| 60 | + $zone->add_offer_shipping_details($jsonld); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - private function get_country_codes( $wc_shipping_zones ) { |
|
| 65 | + private function get_country_codes($wc_shipping_zones) { |
|
| 66 | 66 | $countries = array(); |
| 67 | 67 | |
| 68 | - foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 69 | - if ( ! isset( $wc_shipping_zone->type ) |
|
| 70 | - || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) { |
|
| 68 | + foreach ($wc_shipping_zones as $wc_shipping_zone) { |
|
| 69 | + if ( ! isset($wc_shipping_zone->type) |
|
| 70 | + || ('country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type)) { |
|
| 71 | 71 | continue; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $country = substr( $wc_shipping_zone->code, 0, 2 ); |
|
| 74 | + $country = substr($wc_shipping_zone->code, 0, 2); |
|
| 75 | 75 | |
| 76 | - if ( ! in_array( $country, $countries ) ) { |
|
| 76 | + if ( ! in_array($country, $countries)) { |
|
| 77 | 77 | $countries[] = $country; |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -6,36 +6,36 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Flat_Rate_Shipping_Method extends Shipping_Method { |
| 8 | 8 | |
| 9 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 9 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 10 | 10 | |
| 11 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 12 | - $jsonld['availableDeliveryMethod'] = array(); |
|
| 13 | - } |
|
| 11 | + if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 12 | + $jsonld['availableDeliveryMethod'] = array(); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 16 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 17 | - } |
|
| 15 | + if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 16 | + $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'] ) ) { |
|
| 20 | - array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 21 | - } |
|
| 19 | + if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'] ) ) { |
|
| 20 | + array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 25 | + public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 26 | 26 | |
| 27 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 28 | - $offer_shipping_details['shippingRate'] = array(); |
|
| 29 | - } |
|
| 27 | + if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 28 | + $offer_shipping_details['shippingRate'] = array(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $offer_shipping_details['shippingRate'][] = array( |
|
| 32 | - '@type' => 'MonetaryAmount', |
|
| 33 | - 'name' => $this->wc_shipping_method->get_method_title(), |
|
| 34 | - 'description' => wp_strip_all_tags( $this->wc_shipping_method->get_method_description() ), |
|
| 35 | - 'value' => $this->wc_shipping_method->get_option( 'cost' ), |
|
| 36 | - 'currency' => get_woocommerce_currency(), |
|
| 37 | - ); |
|
| 31 | + $offer_shipping_details['shippingRate'][] = array( |
|
| 32 | + '@type' => 'MonetaryAmount', |
|
| 33 | + 'name' => $this->wc_shipping_method->get_method_title(), |
|
| 34 | + 'description' => wp_strip_all_tags( $this->wc_shipping_method->get_method_description() ), |
|
| 35 | + 'value' => $this->wc_shipping_method->get_option( 'cost' ), |
|
| 36 | + 'currency' => get_woocommerce_currency(), |
|
| 37 | + ); |
|
| 38 | 38 | |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | } |
@@ -6,33 +6,33 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Flat_Rate_Shipping_Method extends Shipping_Method { |
| 8 | 8 | |
| 9 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 9 | + public function add_available_delivery_method(&$jsonld) { |
|
| 10 | 10 | |
| 11 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 11 | + if ( ! isset($jsonld['availableDeliveryMethod'])) { |
|
| 12 | 12 | $jsonld['availableDeliveryMethod'] = array(); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 16 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 15 | + if ( ! is_array($jsonld['availableDeliveryMethod'])) { |
|
| 16 | + $jsonld['availableDeliveryMethod'] = array($jsonld['availableDeliveryMethod']); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'] ) ) { |
|
| 20 | - array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 19 | + if ( ! in_array('ParcelDelivery', $jsonld['availableDeliveryMethod'])) { |
|
| 20 | + array_push($jsonld['availableDeliveryMethod'], 'ParcelDelivery'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 25 | + public function add_shipping_rate(&$offer_shipping_details) { |
|
| 26 | 26 | |
| 27 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 27 | + if ( ! isset($offer_shipping_details['shippingRate'])) { |
|
| 28 | 28 | $offer_shipping_details['shippingRate'] = array(); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $offer_shipping_details['shippingRate'][] = array( |
| 32 | 32 | '@type' => 'MonetaryAmount', |
| 33 | 33 | 'name' => $this->wc_shipping_method->get_method_title(), |
| 34 | - 'description' => wp_strip_all_tags( $this->wc_shipping_method->get_method_description() ), |
|
| 35 | - 'value' => $this->wc_shipping_method->get_option( 'cost' ), |
|
| 34 | + 'description' => wp_strip_all_tags($this->wc_shipping_method->get_method_description()), |
|
| 35 | + 'value' => $this->wc_shipping_method->get_option('cost'), |
|
| 36 | 36 | 'currency' => get_woocommerce_currency(), |
| 37 | 37 | ); |
| 38 | 38 | |
@@ -4,41 +4,41 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Offer_Structured_Data { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @var Shipping_Zones |
|
| 9 | - */ |
|
| 10 | - private $shipping_zones; |
|
| 7 | + /** |
|
| 8 | + * @var Shipping_Zones |
|
| 9 | + */ |
|
| 10 | + private $shipping_zones; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Offer_Structured_Data constructor. |
|
| 14 | - * |
|
| 15 | - * @param Shipping_Zones $shipping_zones |
|
| 16 | - */ |
|
| 17 | - public function __construct( $shipping_zones ) { |
|
| 12 | + /** |
|
| 13 | + * Offer_Structured_Data constructor. |
|
| 14 | + * |
|
| 15 | + * @param Shipping_Zones $shipping_zones |
|
| 16 | + */ |
|
| 17 | + public function __construct( $shipping_zones ) { |
|
| 18 | 18 | |
| 19 | - $this->shipping_zones = $shipping_zones; |
|
| 19 | + $this->shipping_zones = $shipping_zones; |
|
| 20 | 20 | |
| 21 | - add_filter( 'wl_entity_jsonld', array( $this, 'entity_jsonld' ), 10, 2 ); |
|
| 21 | + add_filter( 'wl_entity_jsonld', array( $this, 'entity_jsonld' ), 10, 2 ); |
|
| 22 | 22 | |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function entity_jsonld( $jsonld, $post_id ) { |
|
| 25 | + public function entity_jsonld( $jsonld, $post_id ) { |
|
| 26 | 26 | |
| 27 | - // Bail out if it's not a Product or the offers property isn't set. |
|
| 28 | - if ( ! in_array( 'Product', (array) $jsonld['@type'] ) || ! isset( $jsonld['offers'] ) ) { |
|
| 29 | - return $jsonld; |
|
| 30 | - } |
|
| 27 | + // Bail out if it's not a Product or the offers property isn't set. |
|
| 28 | + if ( ! in_array( 'Product', (array) $jsonld['@type'] ) || ! isset( $jsonld['offers'] ) ) { |
|
| 29 | + return $jsonld; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - if ( ! is_array( $jsonld['offers'] ) || ! is_numeric( key( $jsonld['offers'] ) ) ) { |
|
| 33 | - $jsonld['offers'] = array( $jsonld['offers'] ); |
|
| 34 | - } |
|
| 32 | + if ( ! is_array( $jsonld['offers'] ) || ! is_numeric( key( $jsonld['offers'] ) ) ) { |
|
| 33 | + $jsonld['offers'] = array( $jsonld['offers'] ); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - foreach ( $jsonld['offers'] as &$offer ) { |
|
| 37 | - $this->shipping_zones->add_available_delivery_method( $offer ); |
|
| 38 | - $this->shipping_zones->add_offer_shipping_details( $offer ); |
|
| 39 | - } |
|
| 36 | + foreach ( $jsonld['offers'] as &$offer ) { |
|
| 37 | + $this->shipping_zones->add_available_delivery_method( $offer ); |
|
| 38 | + $this->shipping_zones->add_offer_shipping_details( $offer ); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - return $jsonld; |
|
| 42 | - } |
|
| 41 | + return $jsonld; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | } |
@@ -14,28 +14,28 @@ |
||
| 14 | 14 | * |
| 15 | 15 | * @param Shipping_Zones $shipping_zones |
| 16 | 16 | */ |
| 17 | - public function __construct( $shipping_zones ) { |
|
| 17 | + public function __construct($shipping_zones) { |
|
| 18 | 18 | |
| 19 | 19 | $this->shipping_zones = $shipping_zones; |
| 20 | 20 | |
| 21 | - add_filter( 'wl_entity_jsonld', array( $this, 'entity_jsonld' ), 10, 2 ); |
|
| 21 | + add_filter('wl_entity_jsonld', array($this, 'entity_jsonld'), 10, 2); |
|
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function entity_jsonld( $jsonld, $post_id ) { |
|
| 25 | + public function entity_jsonld($jsonld, $post_id) { |
|
| 26 | 26 | |
| 27 | 27 | // Bail out if it's not a Product or the offers property isn't set. |
| 28 | - if ( ! in_array( 'Product', (array) $jsonld['@type'] ) || ! isset( $jsonld['offers'] ) ) { |
|
| 28 | + if ( ! in_array('Product', (array) $jsonld['@type']) || ! isset($jsonld['offers'])) { |
|
| 29 | 29 | return $jsonld; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if ( ! is_array( $jsonld['offers'] ) || ! is_numeric( key( $jsonld['offers'] ) ) ) { |
|
| 33 | - $jsonld['offers'] = array( $jsonld['offers'] ); |
|
| 32 | + if ( ! is_array($jsonld['offers']) || ! is_numeric(key($jsonld['offers']))) { |
|
| 33 | + $jsonld['offers'] = array($jsonld['offers']); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - foreach ( $jsonld['offers'] as &$offer ) { |
|
| 37 | - $this->shipping_zones->add_available_delivery_method( $offer ); |
|
| 38 | - $this->shipping_zones->add_offer_shipping_details( $offer ); |
|
| 36 | + foreach ($jsonld['offers'] as &$offer) { |
|
| 37 | + $this->shipping_zones->add_available_delivery_method($offer); |
|
| 38 | + $this->shipping_zones->add_offer_shipping_details($offer); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return $jsonld; |
@@ -6,37 +6,37 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Free_Shipping_Shipping_Method extends Shipping_Method { |
| 8 | 8 | |
| 9 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 9 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 10 | 10 | |
| 11 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 12 | - $jsonld['availableDeliveryMethod'] = array(); |
|
| 13 | - } |
|
| 11 | + if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 12 | + $jsonld['availableDeliveryMethod'] = array(); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 16 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 17 | - } |
|
| 15 | + if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 16 | + $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'] ) ) { |
|
| 20 | - array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 21 | - } |
|
| 19 | + if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'] ) ) { |
|
| 20 | + array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 25 | + public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 26 | 26 | |
| 27 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 28 | - $offer_shipping_details['shippingRate'] = array(); |
|
| 29 | - } |
|
| 27 | + if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 28 | + $offer_shipping_details['shippingRate'] = array(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $offer_shipping_details['shippingRate'][] = array( |
|
| 32 | - '@type' => 'MonetaryAmount', |
|
| 33 | - 'name' => $this->wc_shipping_method->get_method_title(), |
|
| 34 | - 'description' => wp_strip_all_tags( $this->wc_shipping_method->get_method_description() ), |
|
| 35 | - 'value' => '0', |
|
| 36 | - 'currency' => get_woocommerce_currency(), |
|
| 37 | - ); |
|
| 31 | + $offer_shipping_details['shippingRate'][] = array( |
|
| 32 | + '@type' => 'MonetaryAmount', |
|
| 33 | + 'name' => $this->wc_shipping_method->get_method_title(), |
|
| 34 | + 'description' => wp_strip_all_tags( $this->wc_shipping_method->get_method_description() ), |
|
| 35 | + 'value' => '0', |
|
| 36 | + 'currency' => get_woocommerce_currency(), |
|
| 37 | + ); |
|
| 38 | 38 | |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | } |
@@ -6,32 +6,32 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Free_Shipping_Shipping_Method extends Shipping_Method { |
| 8 | 8 | |
| 9 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 9 | + public function add_available_delivery_method(&$jsonld) { |
|
| 10 | 10 | |
| 11 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 11 | + if ( ! isset($jsonld['availableDeliveryMethod'])) { |
|
| 12 | 12 | $jsonld['availableDeliveryMethod'] = array(); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 16 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 15 | + if ( ! is_array($jsonld['availableDeliveryMethod'])) { |
|
| 16 | + $jsonld['availableDeliveryMethod'] = array($jsonld['availableDeliveryMethod']); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'] ) ) { |
|
| 20 | - array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 19 | + if ( ! in_array('ParcelDelivery', $jsonld['availableDeliveryMethod'])) { |
|
| 20 | + array_push($jsonld['availableDeliveryMethod'], 'ParcelDelivery'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 25 | + public function add_shipping_rate(&$offer_shipping_details) { |
|
| 26 | 26 | |
| 27 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 27 | + if ( ! isset($offer_shipping_details['shippingRate'])) { |
|
| 28 | 28 | $offer_shipping_details['shippingRate'] = array(); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $offer_shipping_details['shippingRate'][] = array( |
| 32 | 32 | '@type' => 'MonetaryAmount', |
| 33 | 33 | 'name' => $this->wc_shipping_method->get_method_title(), |
| 34 | - 'description' => wp_strip_all_tags( $this->wc_shipping_method->get_method_description() ), |
|
| 34 | + 'description' => wp_strip_all_tags($this->wc_shipping_method->get_method_description()), |
|
| 35 | 35 | 'value' => '0', |
| 36 | 36 | 'currency' => get_woocommerce_currency(), |
| 37 | 37 | ); |
@@ -8,49 +8,49 @@ |
||
| 8 | 8 | |
| 9 | 9 | class Shipping_Method { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @var WC_Shipping_Method $wc_shipping_method |
|
| 13 | - */ |
|
| 14 | - protected $wc_shipping_method; |
|
| 11 | + /** |
|
| 12 | + * @var WC_Shipping_Method $wc_shipping_method |
|
| 13 | + */ |
|
| 14 | + protected $wc_shipping_method; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Shipping_Method constructor. |
|
| 18 | - * |
|
| 19 | - * @param WC_Shipping_Method $wc_shipping_method |
|
| 20 | - */ |
|
| 21 | - public function __construct( $wc_shipping_method ) { |
|
| 22 | - $this->wc_shipping_method = $wc_shipping_method; |
|
| 23 | - } |
|
| 16 | + /** |
|
| 17 | + * Shipping_Method constructor. |
|
| 18 | + * |
|
| 19 | + * @param WC_Shipping_Method $wc_shipping_method |
|
| 20 | + */ |
|
| 21 | + public function __construct( $wc_shipping_method ) { |
|
| 22 | + $this->wc_shipping_method = $wc_shipping_method; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param WC_Shipping_Method $wc_shipping_method |
|
| 27 | - * |
|
| 28 | - * @return Shipping_Method |
|
| 29 | - */ |
|
| 30 | - public static function from_wc_shipping_method( $wc_shipping_method ) { |
|
| 25 | + /** |
|
| 26 | + * @param WC_Shipping_Method $wc_shipping_method |
|
| 27 | + * |
|
| 28 | + * @return Shipping_Method |
|
| 29 | + */ |
|
| 30 | + public static function from_wc_shipping_method( $wc_shipping_method ) { |
|
| 31 | 31 | |
| 32 | - switch ( get_class( $wc_shipping_method ) ) { |
|
| 33 | - case 'WC_Shipping_Local_Pickup': |
|
| 34 | - return new Local_Pickup_Shipping_Method( $wc_shipping_method ); |
|
| 32 | + switch ( get_class( $wc_shipping_method ) ) { |
|
| 33 | + case 'WC_Shipping_Local_Pickup': |
|
| 34 | + return new Local_Pickup_Shipping_Method( $wc_shipping_method ); |
|
| 35 | 35 | |
| 36 | - case 'WC_Shipping_Flat_Rate': |
|
| 37 | - return new Flat_Rate_Shipping_Method( $wc_shipping_method ); |
|
| 36 | + case 'WC_Shipping_Flat_Rate': |
|
| 37 | + return new Flat_Rate_Shipping_Method( $wc_shipping_method ); |
|
| 38 | 38 | |
| 39 | - case 'WC_Shipping_Free_Shipping': |
|
| 40 | - return new Free_Shipping_Shipping_Method( $wc_shipping_method ); |
|
| 39 | + case 'WC_Shipping_Free_Shipping': |
|
| 40 | + return new Free_Shipping_Shipping_Method( $wc_shipping_method ); |
|
| 41 | 41 | |
| 42 | - default: |
|
| 43 | - return new self( $wc_shipping_method ); |
|
| 44 | - } |
|
| 42 | + default: |
|
| 43 | + return new self( $wc_shipping_method ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 48 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 49 | 49 | |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 52 | + public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 53 | 53 | |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | } |
| 57 | 57 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @param WC_Shipping_Method $wc_shipping_method |
| 20 | 20 | */ |
| 21 | - public function __construct( $wc_shipping_method ) { |
|
| 21 | + public function __construct($wc_shipping_method) { |
|
| 22 | 22 | $this->wc_shipping_method = $wc_shipping_method; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -27,29 +27,29 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return Shipping_Method |
| 29 | 29 | */ |
| 30 | - public static function from_wc_shipping_method( $wc_shipping_method ) { |
|
| 30 | + public static function from_wc_shipping_method($wc_shipping_method) { |
|
| 31 | 31 | |
| 32 | - switch ( get_class( $wc_shipping_method ) ) { |
|
| 32 | + switch (get_class($wc_shipping_method)) { |
|
| 33 | 33 | case 'WC_Shipping_Local_Pickup': |
| 34 | - return new Local_Pickup_Shipping_Method( $wc_shipping_method ); |
|
| 34 | + return new Local_Pickup_Shipping_Method($wc_shipping_method); |
|
| 35 | 35 | |
| 36 | 36 | case 'WC_Shipping_Flat_Rate': |
| 37 | - return new Flat_Rate_Shipping_Method( $wc_shipping_method ); |
|
| 37 | + return new Flat_Rate_Shipping_Method($wc_shipping_method); |
|
| 38 | 38 | |
| 39 | 39 | case 'WC_Shipping_Free_Shipping': |
| 40 | - return new Free_Shipping_Shipping_Method( $wc_shipping_method ); |
|
| 40 | + return new Free_Shipping_Shipping_Method($wc_shipping_method); |
|
| 41 | 41 | |
| 42 | 42 | default: |
| 43 | - return new self( $wc_shipping_method ); |
|
| 43 | + return new self($wc_shipping_method); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 48 | + public function add_available_delivery_method(&$jsonld) { |
|
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 52 | + public function add_shipping_rate(&$offer_shipping_details) { |
|
| 53 | 53 | |
| 54 | 54 | } |
| 55 | 55 | |
@@ -6,36 +6,36 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Local_Pickup_Shipping_Method extends Shipping_Method { |
| 8 | 8 | |
| 9 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 9 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 10 | 10 | |
| 11 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 12 | - $jsonld['availableDeliveryMethod'] = array(); |
|
| 13 | - } |
|
| 11 | + if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 12 | + $jsonld['availableDeliveryMethod'] = array(); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 16 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 17 | - } |
|
| 15 | + if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 16 | + $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - if ( ! in_array( 'OnSitePickup', $jsonld['availableDeliveryMethod'] ) ) { |
|
| 20 | - array_push( $jsonld['availableDeliveryMethod'], 'OnSitePickup' ); |
|
| 21 | - } |
|
| 19 | + if ( ! in_array( 'OnSitePickup', $jsonld['availableDeliveryMethod'] ) ) { |
|
| 20 | + array_push( $jsonld['availableDeliveryMethod'], 'OnSitePickup' ); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 25 | + public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 26 | 26 | |
| 27 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 28 | - $offer_shipping_details['shippingRate'] = array(); |
|
| 29 | - } |
|
| 27 | + if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 28 | + $offer_shipping_details['shippingRate'] = array(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $offer_shipping_details['shippingRate'][] = array( |
|
| 32 | - '@type' => 'MonetaryAmount', |
|
| 33 | - 'name' => $this->wc_shipping_method->get_method_title(), |
|
| 34 | - 'description' => wp_strip_all_tags( $this->wc_shipping_method->get_method_description() ), |
|
| 35 | - 'value' => $this->wc_shipping_method->get_option( 'cost' ) ?: '0', |
|
| 36 | - 'currency' => get_woocommerce_currency(), |
|
| 37 | - ); |
|
| 31 | + $offer_shipping_details['shippingRate'][] = array( |
|
| 32 | + '@type' => 'MonetaryAmount', |
|
| 33 | + 'name' => $this->wc_shipping_method->get_method_title(), |
|
| 34 | + 'description' => wp_strip_all_tags( $this->wc_shipping_method->get_method_description() ), |
|
| 35 | + 'value' => $this->wc_shipping_method->get_option( 'cost' ) ?: '0', |
|
| 36 | + 'currency' => get_woocommerce_currency(), |
|
| 37 | + ); |
|
| 38 | 38 | |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | } |
@@ -6,33 +6,33 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Local_Pickup_Shipping_Method extends Shipping_Method { |
| 8 | 8 | |
| 9 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 9 | + public function add_available_delivery_method(&$jsonld) { |
|
| 10 | 10 | |
| 11 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 11 | + if ( ! isset($jsonld['availableDeliveryMethod'])) { |
|
| 12 | 12 | $jsonld['availableDeliveryMethod'] = array(); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 16 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 15 | + if ( ! is_array($jsonld['availableDeliveryMethod'])) { |
|
| 16 | + $jsonld['availableDeliveryMethod'] = array($jsonld['availableDeliveryMethod']); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - if ( ! in_array( 'OnSitePickup', $jsonld['availableDeliveryMethod'] ) ) { |
|
| 20 | - array_push( $jsonld['availableDeliveryMethod'], 'OnSitePickup' ); |
|
| 19 | + if ( ! in_array('OnSitePickup', $jsonld['availableDeliveryMethod'])) { |
|
| 20 | + array_push($jsonld['availableDeliveryMethod'], 'OnSitePickup'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 25 | + public function add_shipping_rate(&$offer_shipping_details) { |
|
| 26 | 26 | |
| 27 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 27 | + if ( ! isset($offer_shipping_details['shippingRate'])) { |
|
| 28 | 28 | $offer_shipping_details['shippingRate'] = array(); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $offer_shipping_details['shippingRate'][] = array( |
| 32 | 32 | '@type' => 'MonetaryAmount', |
| 33 | 33 | 'name' => $this->wc_shipping_method->get_method_title(), |
| 34 | - 'description' => wp_strip_all_tags( $this->wc_shipping_method->get_method_description() ), |
|
| 35 | - 'value' => $this->wc_shipping_method->get_option( 'cost' ) ?: '0', |
|
| 34 | + 'description' => wp_strip_all_tags($this->wc_shipping_method->get_method_description()), |
|
| 35 | + 'value' => $this->wc_shipping_method->get_option('cost') ?: '0', |
|
| 36 | 36 | 'currency' => get_woocommerce_currency(), |
| 37 | 37 | ); |
| 38 | 38 | |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | || ! class_exists( '\WC_Shipping_Zone' ) |
| 9 | 9 | || ! class_exists( '\WC_Shipping_Method' ) |
| 10 | 10 | || ! function_exists( 'get_woocommerce_currency' ) ) { |
| 11 | - return; |
|
| 11 | + return; |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | $shipping_zones = new Shipping_Zones(); |
@@ -4,12 +4,12 @@ |
||
| 4 | 4 | use Wordlift\Shipping_Data\Offer_Structured_Data; |
| 5 | 5 | use Wordlift\Shipping_Data\Shipping_Zones; |
| 6 | 6 | |
| 7 | -if ( ! class_exists( '\WC_Shipping_Zones' ) |
|
| 8 | - || ! class_exists( '\WC_Shipping_Zone' ) |
|
| 9 | - || ! class_exists( '\WC_Shipping_Method' ) |
|
| 10 | - || ! function_exists( 'get_woocommerce_currency' ) ) { |
|
| 7 | +if ( ! class_exists('\WC_Shipping_Zones') |
|
| 8 | + || ! class_exists('\WC_Shipping_Zone') |
|
| 9 | + || ! class_exists('\WC_Shipping_Method') |
|
| 10 | + || ! function_exists('get_woocommerce_currency')) { |
|
| 11 | 11 | return; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | $shipping_zones = new Shipping_Zones(); |
| 15 | -$offer_structured_data = new Offer_Structured_Data( $shipping_zones ); |
|
| 15 | +$offer_structured_data = new Offer_Structured_Data($shipping_zones); |
|
@@ -8,227 +8,227 @@ |
||
| 8 | 8 | |
| 9 | 9 | class Shipping_Zone { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @var WC_Shipping_Zone |
|
| 13 | - */ |
|
| 14 | - private $wc_shipping_zone; |
|
| 11 | + /** |
|
| 12 | + * @var WC_Shipping_Zone |
|
| 13 | + */ |
|
| 14 | + private $wc_shipping_zone; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @var Shipping_Method[] |
|
| 18 | - */ |
|
| 19 | - private $methods; |
|
| 16 | + /** |
|
| 17 | + * @var Shipping_Method[] |
|
| 18 | + */ |
|
| 19 | + private $methods; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - private $country_code; |
|
| 21 | + /** |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + private $country_code; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var string[] |
|
| 28 | - */ |
|
| 29 | - private $regions = array(); |
|
| 26 | + /** |
|
| 27 | + * @var string[] |
|
| 28 | + */ |
|
| 29 | + private $regions = array(); |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var string[] |
|
| 33 | - */ |
|
| 34 | - private $postal_codes = array(); |
|
| 31 | + /** |
|
| 32 | + * @var string[] |
|
| 33 | + */ |
|
| 34 | + private $postal_codes = array(); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var string[] |
|
| 38 | - */ |
|
| 39 | - private $postal_code_prefixes = array(); |
|
| 36 | + /** |
|
| 37 | + * @var string[] |
|
| 38 | + */ |
|
| 39 | + private $postal_code_prefixes = array(); |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var string[] |
|
| 43 | - */ |
|
| 44 | - private $postal_code_ranges = array(); |
|
| 41 | + /** |
|
| 42 | + * @var string[] |
|
| 43 | + */ |
|
| 44 | + private $postal_code_ranges = array(); |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Shipping_Zone constructor. |
|
| 48 | - * |
|
| 49 | - * @param WC_Shipping_Zone $wc_shipping_zone |
|
| 50 | - * @param string $country_code |
|
| 51 | - */ |
|
| 52 | - public function __construct( $wc_shipping_zone, $country_code ) { |
|
| 46 | + /** |
|
| 47 | + * Shipping_Zone constructor. |
|
| 48 | + * |
|
| 49 | + * @param WC_Shipping_Zone $wc_shipping_zone |
|
| 50 | + * @param string $country_code |
|
| 51 | + */ |
|
| 52 | + public function __construct( $wc_shipping_zone, $country_code ) { |
|
| 53 | 53 | |
| 54 | - $this->wc_shipping_zone = $wc_shipping_zone; |
|
| 55 | - $this->country_code = $country_code; |
|
| 54 | + $this->wc_shipping_zone = $wc_shipping_zone; |
|
| 55 | + $this->country_code = $country_code; |
|
| 56 | 56 | |
| 57 | - $this->load_zone_locations(); |
|
| 57 | + $this->load_zone_locations(); |
|
| 58 | 58 | |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - private function load_zone_locations() { |
|
| 61 | + private function load_zone_locations() { |
|
| 62 | 62 | |
| 63 | - $this->regions = array(); |
|
| 64 | - $this->postal_codes = array(); |
|
| 65 | - $this->postal_code_prefixes = array(); |
|
| 66 | - $this->postal_code_ranges = array(); |
|
| 63 | + $this->regions = array(); |
|
| 64 | + $this->postal_codes = array(); |
|
| 65 | + $this->postal_code_prefixes = array(); |
|
| 66 | + $this->postal_code_ranges = array(); |
|
| 67 | 67 | |
| 68 | - // Bail out if country code isn't set. |
|
| 69 | - if ( ! isset( $this->country_code ) ) { |
|
| 70 | - return; |
|
| 71 | - } |
|
| 68 | + // Bail out if country code isn't set. |
|
| 69 | + if ( ! isset( $this->country_code ) ) { |
|
| 70 | + return; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - foreach ( $this->wc_shipping_zone->get_zone_locations() as $zone_location ) { |
|
| 74 | - switch ( $zone_location->type ) { |
|
| 75 | - case 'state': |
|
| 76 | - if ( 0 === strpos( $zone_location->code, "$this->country_code:" ) ) { |
|
| 77 | - $this->regions[] = substr( $zone_location->code, 3 ); |
|
| 78 | - } |
|
| 73 | + foreach ( $this->wc_shipping_zone->get_zone_locations() as $zone_location ) { |
|
| 74 | + switch ( $zone_location->type ) { |
|
| 75 | + case 'state': |
|
| 76 | + if ( 0 === strpos( $zone_location->code, "$this->country_code:" ) ) { |
|
| 77 | + $this->regions[] = substr( $zone_location->code, 3 ); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - break; |
|
| 80 | + break; |
|
| 81 | 81 | |
| 82 | - case 'postcode': |
|
| 83 | - if ( '*' === substr( $zone_location->code, - 1 ) ) { |
|
| 84 | - $this->postal_code_prefixes[] = $zone_location->code; |
|
| 85 | - } else if ( - 1 < strpos( $zone_location->code, '...' ) ) { |
|
| 86 | - $this->postal_code_ranges[] = $zone_location->code; |
|
| 87 | - } else { |
|
| 88 | - $this->postal_codes[] = $zone_location->code; |
|
| 89 | - } |
|
| 82 | + case 'postcode': |
|
| 83 | + if ( '*' === substr( $zone_location->code, - 1 ) ) { |
|
| 84 | + $this->postal_code_prefixes[] = $zone_location->code; |
|
| 85 | + } else if ( - 1 < strpos( $zone_location->code, '...' ) ) { |
|
| 86 | + $this->postal_code_ranges[] = $zone_location->code; |
|
| 87 | + } else { |
|
| 88 | + $this->postal_codes[] = $zone_location->code; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - break; |
|
| 91 | + break; |
|
| 92 | 92 | |
| 93 | - default: |
|
| 94 | - } |
|
| 95 | - } |
|
| 93 | + default: |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - private function load_methods() { |
|
| 99 | + private function load_methods() { |
|
| 100 | 100 | |
| 101 | - $this->methods = array_map( 'Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method', |
|
| 102 | - $this->wc_shipping_zone->get_shipping_methods( true ) ); |
|
| 101 | + $this->methods = array_map( 'Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method', |
|
| 102 | + $this->wc_shipping_zone->get_shipping_methods( true ) ); |
|
| 103 | 103 | |
| 104 | - } |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 106 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 107 | 107 | |
| 108 | - $this->load_methods(); |
|
| 108 | + $this->load_methods(); |
|
| 109 | 109 | |
| 110 | - foreach ( $this->methods as $method ) { |
|
| 111 | - $method->add_available_delivery_method( $jsonld ); |
|
| 112 | - } |
|
| 110 | + foreach ( $this->methods as $method ) { |
|
| 111 | + $method->add_available_delivery_method( $jsonld ); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - public function add_offer_shipping_details( &$jsonld ) { |
|
| 116 | + public function add_offer_shipping_details( &$jsonld ) { |
|
| 117 | 117 | |
| 118 | - $this->load_methods(); |
|
| 118 | + $this->load_methods(); |
|
| 119 | 119 | |
| 120 | - // Ignore the default zone if no methods are configured. |
|
| 121 | - if ( 0 === $this->wc_shipping_zone->get_id() && 0 === count( $this->methods ) ) { |
|
| 122 | - return; |
|
| 123 | - } |
|
| 120 | + // Ignore the default zone if no methods are configured. |
|
| 121 | + if ( 0 === $this->wc_shipping_zone->get_id() && 0 === count( $this->methods ) ) { |
|
| 122 | + return; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - $this->make_sure_shipping_details_exists_and_it_is_an_array( $jsonld ); |
|
| 125 | + $this->make_sure_shipping_details_exists_and_it_is_an_array( $jsonld ); |
|
| 126 | 126 | |
| 127 | - $offer_shipping_details = array( '@type' => 'OfferShippingDetails', ); |
|
| 127 | + $offer_shipping_details = array( '@type' => 'OfferShippingDetails', ); |
|
| 128 | 128 | |
| 129 | - $this->add_shipping_destination( $offer_shipping_details ); |
|
| 129 | + $this->add_shipping_destination( $offer_shipping_details ); |
|
| 130 | 130 | |
| 131 | - /* |
|
| 131 | + /* |
|
| 132 | 132 | * Use Case UC003 |
| 133 | 133 | * 1.4.3 |
| 134 | 134 | * |
| 135 | 135 | * https://editorial.thenextweb.com/wp-admin/admin-ajax.php?action=wl_ttl_cache_cleaner__flush |
| 136 | 136 | */ |
| 137 | - foreach ( $this->methods as $method ) { |
|
| 138 | - $method->add_shipping_rate( $offer_shipping_details ); |
|
| 139 | - } |
|
| 137 | + foreach ( $this->methods as $method ) { |
|
| 138 | + $method->add_shipping_rate( $offer_shipping_details ); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - $jsonld['shippingDetails'][] = $offer_shipping_details; |
|
| 141 | + $jsonld['shippingDetails'][] = $offer_shipping_details; |
|
| 142 | 142 | |
| 143 | - } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - private function make_sure_shipping_details_exists_and_it_is_an_array( &$jsonld ) { |
|
| 145 | + private function make_sure_shipping_details_exists_and_it_is_an_array( &$jsonld ) { |
|
| 146 | 146 | |
| 147 | - if ( ! isset( $jsonld['shippingDetails'] ) ) { |
|
| 148 | - $jsonld['shippingDetails'] = array(); |
|
| 149 | - } |
|
| 147 | + if ( ! isset( $jsonld['shippingDetails'] ) ) { |
|
| 148 | + $jsonld['shippingDetails'] = array(); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - if ( ! is_array( $jsonld['shippingDetails'] ) || |
|
| 152 | - ( ! empty( $jsonld['shippingDetails'] ) && ! is_numeric( key( $jsonld['shippingDetails'] ) ) ) ) { |
|
| 153 | - $jsonld['shippingDetails'] = array( $jsonld['shippingDetails'] ); |
|
| 154 | - } |
|
| 151 | + if ( ! is_array( $jsonld['shippingDetails'] ) || |
|
| 152 | + ( ! empty( $jsonld['shippingDetails'] ) && ! is_numeric( key( $jsonld['shippingDetails'] ) ) ) ) { |
|
| 153 | + $jsonld['shippingDetails'] = array( $jsonld['shippingDetails'] ); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - } |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - private function add_shipping_destination( &$shipping_details ) { |
|
| 158 | + private function add_shipping_destination( &$shipping_details ) { |
|
| 159 | 159 | |
| 160 | - if ( ! isset( $this->country_code ) ) { |
|
| 161 | - return; |
|
| 162 | - } |
|
| 160 | + if ( ! isset( $this->country_code ) ) { |
|
| 161 | + return; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - $shipping_destination = array( |
|
| 165 | - '@type' => 'DefinedRegion', |
|
| 166 | - 'addressCountry' => $this->country_code, |
|
| 167 | - ); |
|
| 164 | + $shipping_destination = array( |
|
| 165 | + '@type' => 'DefinedRegion', |
|
| 166 | + 'addressCountry' => $this->country_code, |
|
| 167 | + ); |
|
| 168 | 168 | |
| 169 | - $this->add_address_region( $shipping_destination ); |
|
| 170 | - $this->add_postal_code( $shipping_destination ); |
|
| 171 | - $this->add_postal_code_prefix( $shipping_destination ); |
|
| 172 | - $this->add_postal_code_range( $shipping_destination ); |
|
| 169 | + $this->add_address_region( $shipping_destination ); |
|
| 170 | + $this->add_postal_code( $shipping_destination ); |
|
| 171 | + $this->add_postal_code_prefix( $shipping_destination ); |
|
| 172 | + $this->add_postal_code_range( $shipping_destination ); |
|
| 173 | 173 | |
| 174 | - $shipping_details['shippingDestination'] = $shipping_destination; |
|
| 174 | + $shipping_details['shippingDestination'] = $shipping_destination; |
|
| 175 | 175 | |
| 176 | 176 | |
| 177 | - } |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - private function add_address_region( &$shipping_destination ) { |
|
| 179 | + private function add_address_region( &$shipping_destination ) { |
|
| 180 | 180 | |
| 181 | - if ( empty( $this->regions ) ) { |
|
| 182 | - return; |
|
| 183 | - } |
|
| 181 | + if ( empty( $this->regions ) ) { |
|
| 182 | + return; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - $shipping_destination['addressRegion'] = $this->regions; |
|
| 185 | + $shipping_destination['addressRegion'] = $this->regions; |
|
| 186 | 186 | |
| 187 | - } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - private function add_postal_code( &$shipping_destination ) { |
|
| 189 | + private function add_postal_code( &$shipping_destination ) { |
|
| 190 | 190 | |
| 191 | - if ( empty( $this->postal_codes ) ) { |
|
| 192 | - return; |
|
| 193 | - } |
|
| 191 | + if ( empty( $this->postal_codes ) ) { |
|
| 192 | + return; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - $shipping_destination['postalCode'] = $this->postal_codes; |
|
| 195 | + $shipping_destination['postalCode'] = $this->postal_codes; |
|
| 196 | 196 | |
| 197 | - } |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - private function add_postal_code_prefix( &$shipping_destination ) { |
|
| 199 | + private function add_postal_code_prefix( &$shipping_destination ) { |
|
| 200 | 200 | |
| 201 | - if ( empty( $this->postal_code_prefixes ) ) { |
|
| 202 | - return; |
|
| 203 | - } |
|
| 201 | + if ( empty( $this->postal_code_prefixes ) ) { |
|
| 202 | + return; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - foreach ( $this->postal_code_prefixes as $postal_code_prefix ) { |
|
| 206 | - $shipping_destination['postalCodePrefix'][] = substr( $postal_code_prefix, 0, - 1 ); |
|
| 207 | - } |
|
| 205 | + foreach ( $this->postal_code_prefixes as $postal_code_prefix ) { |
|
| 206 | + $shipping_destination['postalCodePrefix'][] = substr( $postal_code_prefix, 0, - 1 ); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - } |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - private function add_postal_code_range( &$shipping_destination ) { |
|
| 211 | + private function add_postal_code_range( &$shipping_destination ) { |
|
| 212 | 212 | |
| 213 | - if ( empty( $this->postal_code_ranges ) ) { |
|
| 214 | - return; |
|
| 215 | - } |
|
| 213 | + if ( empty( $this->postal_code_ranges ) ) { |
|
| 214 | + return; |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - $shipping_destination['postalCodeRanges'] = array(); |
|
| 218 | - foreach ( $this->postal_code_ranges as $post_code_range ) { |
|
| 219 | - $range = explode( '...', $post_code_range ); |
|
| 217 | + $shipping_destination['postalCodeRanges'] = array(); |
|
| 218 | + foreach ( $this->postal_code_ranges as $post_code_range ) { |
|
| 219 | + $range = explode( '...', $post_code_range ); |
|
| 220 | 220 | |
| 221 | - $shipping_destination['postalCodeRanges'][] = array( |
|
| 222 | - 'postalCodeBegin' => $range[0], |
|
| 223 | - 'postalCodeEnd' => $range[1], |
|
| 224 | - ); |
|
| 225 | - } |
|
| 221 | + $shipping_destination['postalCodeRanges'][] = array( |
|
| 222 | + 'postalCodeBegin' => $range[0], |
|
| 223 | + 'postalCodeEnd' => $range[1], |
|
| 224 | + ); |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - public static function from_wc_shipping_zone( $wc_shipping_zone, $country_code = null ) { |
|
| 229 | + public static function from_wc_shipping_zone( $wc_shipping_zone, $country_code = null ) { |
|
| 230 | 230 | |
| 231 | - return new self( $wc_shipping_zone, $country_code ); |
|
| 232 | - } |
|
| 231 | + return new self( $wc_shipping_zone, $country_code ); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | } |
| 235 | 235 | \ No newline at end of file |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param WC_Shipping_Zone $wc_shipping_zone |
| 50 | 50 | * @param string $country_code |
| 51 | 51 | */ |
| 52 | - public function __construct( $wc_shipping_zone, $country_code ) { |
|
| 52 | + public function __construct($wc_shipping_zone, $country_code) { |
|
| 53 | 53 | |
| 54 | 54 | $this->wc_shipping_zone = $wc_shipping_zone; |
| 55 | 55 | $this->country_code = $country_code; |
@@ -66,23 +66,23 @@ discard block |
||
| 66 | 66 | $this->postal_code_ranges = array(); |
| 67 | 67 | |
| 68 | 68 | // Bail out if country code isn't set. |
| 69 | - if ( ! isset( $this->country_code ) ) { |
|
| 69 | + if ( ! isset($this->country_code)) { |
|
| 70 | 70 | return; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - foreach ( $this->wc_shipping_zone->get_zone_locations() as $zone_location ) { |
|
| 74 | - switch ( $zone_location->type ) { |
|
| 73 | + foreach ($this->wc_shipping_zone->get_zone_locations() as $zone_location) { |
|
| 74 | + switch ($zone_location->type) { |
|
| 75 | 75 | case 'state': |
| 76 | - if ( 0 === strpos( $zone_location->code, "$this->country_code:" ) ) { |
|
| 77 | - $this->regions[] = substr( $zone_location->code, 3 ); |
|
| 76 | + if (0 === strpos($zone_location->code, "$this->country_code:")) { |
|
| 77 | + $this->regions[] = substr($zone_location->code, 3); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | break; |
| 81 | 81 | |
| 82 | 82 | case 'postcode': |
| 83 | - if ( '*' === substr( $zone_location->code, - 1 ) ) { |
|
| 83 | + if ('*' === substr($zone_location->code, - 1)) { |
|
| 84 | 84 | $this->postal_code_prefixes[] = $zone_location->code; |
| 85 | - } else if ( - 1 < strpos( $zone_location->code, '...' ) ) { |
|
| 85 | + } else if ( -1 < strpos($zone_location->code, '...') ) { |
|
| 86 | 86 | $this->postal_code_ranges[] = $zone_location->code; |
| 87 | 87 | } else { |
| 88 | 88 | $this->postal_codes[] = $zone_location->code; |
@@ -98,35 +98,35 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | private function load_methods() { |
| 100 | 100 | |
| 101 | - $this->methods = array_map( 'Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method', |
|
| 102 | - $this->wc_shipping_zone->get_shipping_methods( true ) ); |
|
| 101 | + $this->methods = array_map('Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method', |
|
| 102 | + $this->wc_shipping_zone->get_shipping_methods(true)); |
|
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 106 | + public function add_available_delivery_method(&$jsonld) { |
|
| 107 | 107 | |
| 108 | 108 | $this->load_methods(); |
| 109 | 109 | |
| 110 | - foreach ( $this->methods as $method ) { |
|
| 111 | - $method->add_available_delivery_method( $jsonld ); |
|
| 110 | + foreach ($this->methods as $method) { |
|
| 111 | + $method->add_available_delivery_method($jsonld); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public function add_offer_shipping_details( &$jsonld ) { |
|
| 116 | + public function add_offer_shipping_details(&$jsonld) { |
|
| 117 | 117 | |
| 118 | 118 | $this->load_methods(); |
| 119 | 119 | |
| 120 | 120 | // Ignore the default zone if no methods are configured. |
| 121 | - if ( 0 === $this->wc_shipping_zone->get_id() && 0 === count( $this->methods ) ) { |
|
| 121 | + if (0 === $this->wc_shipping_zone->get_id() && 0 === count($this->methods)) { |
|
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $this->make_sure_shipping_details_exists_and_it_is_an_array( $jsonld ); |
|
| 125 | + $this->make_sure_shipping_details_exists_and_it_is_an_array($jsonld); |
|
| 126 | 126 | |
| 127 | - $offer_shipping_details = array( '@type' => 'OfferShippingDetails', ); |
|
| 127 | + $offer_shipping_details = array('@type' => 'OfferShippingDetails',); |
|
| 128 | 128 | |
| 129 | - $this->add_shipping_destination( $offer_shipping_details ); |
|
| 129 | + $this->add_shipping_destination($offer_shipping_details); |
|
| 130 | 130 | |
| 131 | 131 | /* |
| 132 | 132 | * Use Case UC003 |
@@ -134,30 +134,30 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * https://editorial.thenextweb.com/wp-admin/admin-ajax.php?action=wl_ttl_cache_cleaner__flush |
| 136 | 136 | */ |
| 137 | - foreach ( $this->methods as $method ) { |
|
| 138 | - $method->add_shipping_rate( $offer_shipping_details ); |
|
| 137 | + foreach ($this->methods as $method) { |
|
| 138 | + $method->add_shipping_rate($offer_shipping_details); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $jsonld['shippingDetails'][] = $offer_shipping_details; |
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - private function make_sure_shipping_details_exists_and_it_is_an_array( &$jsonld ) { |
|
| 145 | + private function make_sure_shipping_details_exists_and_it_is_an_array(&$jsonld) { |
|
| 146 | 146 | |
| 147 | - if ( ! isset( $jsonld['shippingDetails'] ) ) { |
|
| 147 | + if ( ! isset($jsonld['shippingDetails'])) { |
|
| 148 | 148 | $jsonld['shippingDetails'] = array(); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if ( ! is_array( $jsonld['shippingDetails'] ) || |
|
| 152 | - ( ! empty( $jsonld['shippingDetails'] ) && ! is_numeric( key( $jsonld['shippingDetails'] ) ) ) ) { |
|
| 153 | - $jsonld['shippingDetails'] = array( $jsonld['shippingDetails'] ); |
|
| 151 | + if ( ! is_array($jsonld['shippingDetails']) || |
|
| 152 | + ( ! empty($jsonld['shippingDetails']) && ! is_numeric(key($jsonld['shippingDetails'])))) { |
|
| 153 | + $jsonld['shippingDetails'] = array($jsonld['shippingDetails']); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - private function add_shipping_destination( &$shipping_details ) { |
|
| 158 | + private function add_shipping_destination(&$shipping_details) { |
|
| 159 | 159 | |
| 160 | - if ( ! isset( $this->country_code ) ) { |
|
| 160 | + if ( ! isset($this->country_code)) { |
|
| 161 | 161 | return; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -166,19 +166,19 @@ discard block |
||
| 166 | 166 | 'addressCountry' => $this->country_code, |
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | - $this->add_address_region( $shipping_destination ); |
|
| 170 | - $this->add_postal_code( $shipping_destination ); |
|
| 171 | - $this->add_postal_code_prefix( $shipping_destination ); |
|
| 172 | - $this->add_postal_code_range( $shipping_destination ); |
|
| 169 | + $this->add_address_region($shipping_destination); |
|
| 170 | + $this->add_postal_code($shipping_destination); |
|
| 171 | + $this->add_postal_code_prefix($shipping_destination); |
|
| 172 | + $this->add_postal_code_range($shipping_destination); |
|
| 173 | 173 | |
| 174 | 174 | $shipping_details['shippingDestination'] = $shipping_destination; |
| 175 | 175 | |
| 176 | 176 | |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - private function add_address_region( &$shipping_destination ) { |
|
| 179 | + private function add_address_region(&$shipping_destination) { |
|
| 180 | 180 | |
| 181 | - if ( empty( $this->regions ) ) { |
|
| 181 | + if (empty($this->regions)) { |
|
| 182 | 182 | return; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - private function add_postal_code( &$shipping_destination ) { |
|
| 189 | + private function add_postal_code(&$shipping_destination) { |
|
| 190 | 190 | |
| 191 | - if ( empty( $this->postal_codes ) ) { |
|
| 191 | + if (empty($this->postal_codes)) { |
|
| 192 | 192 | return; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -196,27 +196,27 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - private function add_postal_code_prefix( &$shipping_destination ) { |
|
| 199 | + private function add_postal_code_prefix(&$shipping_destination) { |
|
| 200 | 200 | |
| 201 | - if ( empty( $this->postal_code_prefixes ) ) { |
|
| 201 | + if (empty($this->postal_code_prefixes)) { |
|
| 202 | 202 | return; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - foreach ( $this->postal_code_prefixes as $postal_code_prefix ) { |
|
| 206 | - $shipping_destination['postalCodePrefix'][] = substr( $postal_code_prefix, 0, - 1 ); |
|
| 205 | + foreach ($this->postal_code_prefixes as $postal_code_prefix) { |
|
| 206 | + $shipping_destination['postalCodePrefix'][] = substr($postal_code_prefix, 0, - 1); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - private function add_postal_code_range( &$shipping_destination ) { |
|
| 211 | + private function add_postal_code_range(&$shipping_destination) { |
|
| 212 | 212 | |
| 213 | - if ( empty( $this->postal_code_ranges ) ) { |
|
| 213 | + if (empty($this->postal_code_ranges)) { |
|
| 214 | 214 | return; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | $shipping_destination['postalCodeRanges'] = array(); |
| 218 | - foreach ( $this->postal_code_ranges as $post_code_range ) { |
|
| 219 | - $range = explode( '...', $post_code_range ); |
|
| 218 | + foreach ($this->postal_code_ranges as $post_code_range) { |
|
| 219 | + $range = explode('...', $post_code_range); |
|
| 220 | 220 | |
| 221 | 221 | $shipping_destination['postalCodeRanges'][] = array( |
| 222 | 222 | 'postalCodeBegin' => $range[0], |
@@ -226,9 +226,9 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - public static function from_wc_shipping_zone( $wc_shipping_zone, $country_code = null ) { |
|
| 229 | + public static function from_wc_shipping_zone($wc_shipping_zone, $country_code = null) { |
|
| 230 | 230 | |
| 231 | - return new self( $wc_shipping_zone, $country_code ); |
|
| 231 | + return new self($wc_shipping_zone, $country_code); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | } |
| 235 | 235 | \ No newline at end of file |