@@ -4,57 +4,57 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Flat_Rate_Shipping_Method extends Shipping_Method { |
| 6 | 6 | |
| 7 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 7 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 8 | 8 | |
| 9 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 10 | - $jsonld['availableDeliveryMethod'] = array(); |
|
| 11 | - } |
|
| 9 | + if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 10 | + $jsonld['availableDeliveryMethod'] = array(); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 14 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 15 | - } |
|
| 13 | + if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 14 | + $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'], true ) ) { |
|
| 18 | - array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 19 | - } |
|
| 17 | + if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'], true ) ) { |
|
| 18 | + array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 23 | + public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 24 | 24 | |
| 25 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 26 | - $offer_shipping_details['shippingRate'] = array(); |
|
| 27 | - } |
|
| 25 | + if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 26 | + $offer_shipping_details['shippingRate'] = array(); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - $description = isset( $this->wc_shipping_method->instance_settings['description'] ) |
|
| 30 | - ? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : ''; |
|
| 29 | + $description = isset( $this->wc_shipping_method->instance_settings['description'] ) |
|
| 30 | + ? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : ''; |
|
| 31 | 31 | |
| 32 | - $shipping_rate = array( |
|
| 33 | - '@type' => 'MonetaryAmount', |
|
| 34 | - 'name' => $this->wc_shipping_method->get_title(), |
|
| 35 | - 'description' => $description, |
|
| 36 | - 'value' => $this->wc_shipping_method->get_option( 'cost' ), |
|
| 37 | - 'currency' => get_woocommerce_currency(), |
|
| 38 | - ); |
|
| 32 | + $shipping_rate = array( |
|
| 33 | + '@type' => 'MonetaryAmount', |
|
| 34 | + 'name' => $this->wc_shipping_method->get_title(), |
|
| 35 | + 'description' => $description, |
|
| 36 | + 'value' => $this->wc_shipping_method->get_option( 'cost' ), |
|
| 37 | + 'currency' => get_woocommerce_currency(), |
|
| 38 | + ); |
|
| 39 | 39 | |
| 40 | - $this->change_to_manual_currency( $shipping_rate ); |
|
| 40 | + $this->change_to_manual_currency( $shipping_rate ); |
|
| 41 | 41 | |
| 42 | - $offer_shipping_details['shippingRate'][] = $shipping_rate; |
|
| 42 | + $offer_shipping_details['shippingRate'][] = $shipping_rate; |
|
| 43 | 43 | |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - protected function set_value_with_currency_codes( &$shipping_rate, $instance, $currency_codes ) { |
|
| 46 | + protected function set_value_with_currency_codes( &$shipping_rate, $instance, $currency_codes ) { |
|
| 47 | 47 | |
| 48 | - // Get the first manual price. |
|
| 49 | - foreach ( $currency_codes as $code ) { |
|
| 50 | - if ( isset( $instance[ "cost_$code" ] ) ) { |
|
| 51 | - $shipping_rate['value'] = $instance[ "cost_$code" ]; |
|
| 52 | - $shipping_rate['currency'] = $code; |
|
| 48 | + // Get the first manual price. |
|
| 49 | + foreach ( $currency_codes as $code ) { |
|
| 50 | + if ( isset( $instance[ "cost_$code" ] ) ) { |
|
| 51 | + $shipping_rate['value'] = $instance[ "cost_$code" ]; |
|
| 52 | + $shipping_rate['currency'] = $code; |
|
| 53 | 53 | |
| 54 | - return; |
|
| 55 | - } |
|
| 56 | - } |
|
| 54 | + return; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | } |
@@ -4,51 +4,51 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Flat_Rate_Shipping_Method extends Shipping_Method { |
| 6 | 6 | |
| 7 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 7 | + public function add_available_delivery_method(&$jsonld) { |
|
| 8 | 8 | |
| 9 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 9 | + if ( ! isset($jsonld['availableDeliveryMethod'])) { |
|
| 10 | 10 | $jsonld['availableDeliveryMethod'] = array(); |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 14 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 13 | + if ( ! is_array($jsonld['availableDeliveryMethod'])) { |
|
| 14 | + $jsonld['availableDeliveryMethod'] = array($jsonld['availableDeliveryMethod']); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'], true ) ) { |
|
| 18 | - array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 17 | + if ( ! in_array('ParcelDelivery', $jsonld['availableDeliveryMethod'], true)) { |
|
| 18 | + array_push($jsonld['availableDeliveryMethod'], 'ParcelDelivery'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 23 | + public function add_shipping_rate(&$offer_shipping_details) { |
|
| 24 | 24 | |
| 25 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 25 | + if ( ! isset($offer_shipping_details['shippingRate'])) { |
|
| 26 | 26 | $offer_shipping_details['shippingRate'] = array(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - $description = isset( $this->wc_shipping_method->instance_settings['description'] ) |
|
| 30 | - ? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : ''; |
|
| 29 | + $description = isset($this->wc_shipping_method->instance_settings['description']) |
|
| 30 | + ? wp_strip_all_tags($this->wc_shipping_method->instance_settings['description']) : ''; |
|
| 31 | 31 | |
| 32 | 32 | $shipping_rate = array( |
| 33 | 33 | '@type' => 'MonetaryAmount', |
| 34 | 34 | 'name' => $this->wc_shipping_method->get_title(), |
| 35 | 35 | 'description' => $description, |
| 36 | - 'value' => $this->wc_shipping_method->get_option( 'cost' ), |
|
| 36 | + 'value' => $this->wc_shipping_method->get_option('cost'), |
|
| 37 | 37 | 'currency' => get_woocommerce_currency(), |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | - $this->change_to_manual_currency( $shipping_rate ); |
|
| 40 | + $this->change_to_manual_currency($shipping_rate); |
|
| 41 | 41 | |
| 42 | 42 | $offer_shipping_details['shippingRate'][] = $shipping_rate; |
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - protected function set_value_with_currency_codes( &$shipping_rate, $instance, $currency_codes ) { |
|
| 46 | + protected function set_value_with_currency_codes(&$shipping_rate, $instance, $currency_codes) { |
|
| 47 | 47 | |
| 48 | 48 | // Get the first manual price. |
| 49 | - foreach ( $currency_codes as $code ) { |
|
| 50 | - if ( isset( $instance[ "cost_$code" ] ) ) { |
|
| 51 | - $shipping_rate['value'] = $instance[ "cost_$code" ]; |
|
| 49 | + foreach ($currency_codes as $code) { |
|
| 50 | + if (isset($instance["cost_$code"])) { |
|
| 51 | + $shipping_rate['value'] = $instance["cost_$code"]; |
|
| 52 | 52 | $shipping_rate['currency'] = $code; |
| 53 | 53 | |
| 54 | 54 | return; |
@@ -4,51 +4,51 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Free_Shipping_Shipping_Method extends Shipping_Method { |
| 6 | 6 | |
| 7 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 7 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 8 | 8 | |
| 9 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 10 | - $jsonld['availableDeliveryMethod'] = array(); |
|
| 11 | - } |
|
| 9 | + if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 10 | + $jsonld['availableDeliveryMethod'] = array(); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 14 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 15 | - } |
|
| 13 | + if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 14 | + $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'], true ) ) { |
|
| 18 | - array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 19 | - } |
|
| 17 | + if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'], true ) ) { |
|
| 18 | + array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 23 | + public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 24 | 24 | |
| 25 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 26 | - $offer_shipping_details['shippingRate'] = array(); |
|
| 27 | - } |
|
| 25 | + if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 26 | + $offer_shipping_details['shippingRate'] = array(); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - $description = isset( $this->wc_shipping_method->instance_settings['description'] ) |
|
| 30 | - ? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : ''; |
|
| 29 | + $description = isset( $this->wc_shipping_method->instance_settings['description'] ) |
|
| 30 | + ? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : ''; |
|
| 31 | 31 | |
| 32 | - $shipping_rate = array( |
|
| 33 | - '@type' => 'MonetaryAmount', |
|
| 34 | - 'name' => $this->wc_shipping_method->get_title(), |
|
| 35 | - 'description' => $description, |
|
| 36 | - 'value' => '0', |
|
| 37 | - 'currency' => get_woocommerce_currency(), |
|
| 38 | - ); |
|
| 32 | + $shipping_rate = array( |
|
| 33 | + '@type' => 'MonetaryAmount', |
|
| 34 | + 'name' => $this->wc_shipping_method->get_title(), |
|
| 35 | + 'description' => $description, |
|
| 36 | + 'value' => '0', |
|
| 37 | + 'currency' => get_woocommerce_currency(), |
|
| 38 | + ); |
|
| 39 | 39 | |
| 40 | - $this->change_to_manual_currency( $shipping_rate ); |
|
| 40 | + $this->change_to_manual_currency( $shipping_rate ); |
|
| 41 | 41 | |
| 42 | - $offer_shipping_details['shippingRate'][] = $shipping_rate; |
|
| 42 | + $offer_shipping_details['shippingRate'][] = $shipping_rate; |
|
| 43 | 43 | |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - protected function set_value_with_currency_codes( &$shipping_rate, $instance, $currency_codes ) { |
|
| 46 | + protected function set_value_with_currency_codes( &$shipping_rate, $instance, $currency_codes ) { |
|
| 47 | 47 | |
| 48 | - if ( ! empty( $currency_codes ) ) { |
|
| 49 | - $shipping_rate['currency'] = $currency_codes[0]; |
|
| 50 | - } |
|
| 48 | + if ( ! empty( $currency_codes ) ) { |
|
| 49 | + $shipping_rate['currency'] = $currency_codes[0]; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | } |
@@ -4,30 +4,30 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Free_Shipping_Shipping_Method extends Shipping_Method { |
| 6 | 6 | |
| 7 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 7 | + public function add_available_delivery_method(&$jsonld) { |
|
| 8 | 8 | |
| 9 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 9 | + if ( ! isset($jsonld['availableDeliveryMethod'])) { |
|
| 10 | 10 | $jsonld['availableDeliveryMethod'] = array(); |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 14 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 13 | + if ( ! is_array($jsonld['availableDeliveryMethod'])) { |
|
| 14 | + $jsonld['availableDeliveryMethod'] = array($jsonld['availableDeliveryMethod']); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'], true ) ) { |
|
| 18 | - array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 17 | + if ( ! in_array('ParcelDelivery', $jsonld['availableDeliveryMethod'], true)) { |
|
| 18 | + array_push($jsonld['availableDeliveryMethod'], 'ParcelDelivery'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 23 | + public function add_shipping_rate(&$offer_shipping_details) { |
|
| 24 | 24 | |
| 25 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 25 | + if ( ! isset($offer_shipping_details['shippingRate'])) { |
|
| 26 | 26 | $offer_shipping_details['shippingRate'] = array(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - $description = isset( $this->wc_shipping_method->instance_settings['description'] ) |
|
| 30 | - ? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : ''; |
|
| 29 | + $description = isset($this->wc_shipping_method->instance_settings['description']) |
|
| 30 | + ? wp_strip_all_tags($this->wc_shipping_method->instance_settings['description']) : ''; |
|
| 31 | 31 | |
| 32 | 32 | $shipping_rate = array( |
| 33 | 33 | '@type' => 'MonetaryAmount', |
@@ -37,15 +37,15 @@ discard block |
||
| 37 | 37 | 'currency' => get_woocommerce_currency(), |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | - $this->change_to_manual_currency( $shipping_rate ); |
|
| 40 | + $this->change_to_manual_currency($shipping_rate); |
|
| 41 | 41 | |
| 42 | 42 | $offer_shipping_details['shippingRate'][] = $shipping_rate; |
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - protected function set_value_with_currency_codes( &$shipping_rate, $instance, $currency_codes ) { |
|
| 46 | + protected function set_value_with_currency_codes(&$shipping_rate, $instance, $currency_codes) { |
|
| 47 | 47 | |
| 48 | - if ( ! empty( $currency_codes ) ) { |
|
| 48 | + if ( ! empty($currency_codes)) { |
|
| 49 | 49 | $shipping_rate['currency'] = $currency_codes[0]; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -7,124 +7,124 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Shipping_Method { |
| 9 | 9 | |
| 10 | - private $wcml; |
|
| 11 | - |
|
| 12 | - /** |
|
| 13 | - * @var WC_Shipping_Method $wc_shipping_method |
|
| 14 | - */ |
|
| 15 | - protected $wc_shipping_method; |
|
| 10 | + private $wcml; |
|
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * @var WC_Shipping_Method $wc_shipping_method |
|
| 14 | + */ |
|
| 15 | + protected $wc_shipping_method; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Shipping_Method constructor. |
|
| 19 | - * |
|
| 20 | - * @param WC_Shipping_Method $wc_shipping_method |
|
| 21 | - */ |
|
| 22 | - public function __construct( $wc_shipping_method ) { |
|
| 23 | - $this->wc_shipping_method = $wc_shipping_method; |
|
| 24 | - } |
|
| 17 | + /** |
|
| 18 | + * Shipping_Method constructor. |
|
| 19 | + * |
|
| 20 | + * @param WC_Shipping_Method $wc_shipping_method |
|
| 21 | + */ |
|
| 22 | + public function __construct( $wc_shipping_method ) { |
|
| 23 | + $this->wc_shipping_method = $wc_shipping_method; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @param WC_Shipping_Method $wc_shipping_method |
|
| 28 | - * |
|
| 29 | - * @return Shipping_Method |
|
| 30 | - */ |
|
| 31 | - public static function from_wc_shipping_method( $wc_shipping_method ) { |
|
| 26 | + /** |
|
| 27 | + * @param WC_Shipping_Method $wc_shipping_method |
|
| 28 | + * |
|
| 29 | + * @return Shipping_Method |
|
| 30 | + */ |
|
| 31 | + public static function from_wc_shipping_method( $wc_shipping_method ) { |
|
| 32 | 32 | |
| 33 | - switch ( get_class( $wc_shipping_method ) ) { |
|
| 34 | - case 'WC_Shipping_Local_Pickup': |
|
| 35 | - return new Local_Pickup_Shipping_Method( $wc_shipping_method ); |
|
| 33 | + switch ( get_class( $wc_shipping_method ) ) { |
|
| 34 | + case 'WC_Shipping_Local_Pickup': |
|
| 35 | + return new Local_Pickup_Shipping_Method( $wc_shipping_method ); |
|
| 36 | 36 | |
| 37 | - case 'WC_Shipping_Flat_Rate': |
|
| 38 | - return new Flat_Rate_Shipping_Method( $wc_shipping_method ); |
|
| 37 | + case 'WC_Shipping_Flat_Rate': |
|
| 38 | + return new Flat_Rate_Shipping_Method( $wc_shipping_method ); |
|
| 39 | 39 | |
| 40 | - case 'WC_Shipping_Free_Shipping': |
|
| 41 | - return new Free_Shipping_Shipping_Method( $wc_shipping_method ); |
|
| 40 | + case 'WC_Shipping_Free_Shipping': |
|
| 41 | + return new Free_Shipping_Shipping_Method( $wc_shipping_method ); |
|
| 42 | 42 | |
| 43 | - default: |
|
| 44 | - return new self( $wc_shipping_method ); |
|
| 45 | - } |
|
| 43 | + default: |
|
| 44 | + return new self( $wc_shipping_method ); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 50 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 49 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 50 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 51 | 51 | |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 55 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 54 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 55 | + public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 56 | 56 | |
| 57 | - } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function add_transit_time( &$shipping_delivery_time ) { |
|
| 59 | + public function add_transit_time( &$shipping_delivery_time ) { |
|
| 60 | 60 | |
| 61 | - $prefix = "wcsdt_transit_m{$this->wc_shipping_method->get_instance_id()}"; |
|
| 62 | - $property = 'transitTime'; |
|
| 61 | + $prefix = "wcsdt_transit_m{$this->wc_shipping_method->get_instance_id()}"; |
|
| 62 | + $property = 'transitTime'; |
|
| 63 | 63 | |
| 64 | - $option = get_option( 'wpsso_options' ); |
|
| 64 | + $option = get_option( 'wpsso_options' ); |
|
| 65 | 65 | |
| 66 | - if ( empty( $option[ "{$prefix}_unit_code" ] ) |
|
| 67 | - || ! isset( $option[ "{$prefix}_minimum" ] ) |
|
| 68 | - || ! isset( $option[ "{$prefix}_maximum" ] ) |
|
| 69 | - || ! is_numeric( $option[ "{$prefix}_minimum" ] ) |
|
| 70 | - || ! is_numeric( $option[ "{$prefix}_maximum" ] ) ) { |
|
| 71 | - return; |
|
| 72 | - } |
|
| 66 | + if ( empty( $option[ "{$prefix}_unit_code" ] ) |
|
| 67 | + || ! isset( $option[ "{$prefix}_minimum" ] ) |
|
| 68 | + || ! isset( $option[ "{$prefix}_maximum" ] ) |
|
| 69 | + || ! is_numeric( $option[ "{$prefix}_minimum" ] ) |
|
| 70 | + || ! is_numeric( $option[ "{$prefix}_maximum" ] ) ) { |
|
| 71 | + return; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $unit_code = $option[ "{$prefix}_unit_code" ]; |
|
| 75 | - $minimum = $option[ "{$prefix}_minimum" ]; |
|
| 76 | - $maximum = $option[ "{$prefix}_maximum" ]; |
|
| 74 | + $unit_code = $option[ "{$prefix}_unit_code" ]; |
|
| 75 | + $minimum = $option[ "{$prefix}_minimum" ]; |
|
| 76 | + $maximum = $option[ "{$prefix}_maximum" ]; |
|
| 77 | 77 | |
| 78 | - if ( 'HUR' === $unit_code ) { |
|
| 79 | - $minimum = floor( $minimum / 24.0 ); |
|
| 80 | - $maximum = ceil( $maximum / 24.0 ); |
|
| 81 | - } |
|
| 78 | + if ( 'HUR' === $unit_code ) { |
|
| 79 | + $minimum = floor( $minimum / 24.0 ); |
|
| 80 | + $maximum = ceil( $maximum / 24.0 ); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - $shipping_delivery_time[ $property ] = array( |
|
| 84 | - '@type' => 'QuantitativeValue', |
|
| 85 | - 'minValue' => intval( $minimum ), |
|
| 86 | - 'maxValue' => intval( $maximum ), |
|
| 87 | - ); |
|
| 83 | + $shipping_delivery_time[ $property ] = array( |
|
| 84 | + '@type' => 'QuantitativeValue', |
|
| 85 | + 'minValue' => intval( $minimum ), |
|
| 86 | + 'maxValue' => intval( $maximum ), |
|
| 87 | + ); |
|
| 88 | 88 | |
| 89 | - } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - protected function change_to_manual_currency( &$shipping_rate ) { |
|
| 92 | - // WCML not available. |
|
| 93 | - if ( ! $this::wcml_requirements() ) { |
|
| 94 | - return; |
|
| 95 | - } |
|
| 91 | + protected function change_to_manual_currency( &$shipping_rate ) { |
|
| 92 | + // WCML not available. |
|
| 93 | + if ( ! $this::wcml_requirements() ) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - // Get WCML. |
|
| 98 | - if ( ! isset( $this->wcml ) ) { |
|
| 99 | - $this->wcml = new WCML_Multi_Currency(); |
|
| 100 | - } |
|
| 97 | + // Get WCML. |
|
| 98 | + if ( ! isset( $this->wcml ) ) { |
|
| 99 | + $this->wcml = new WCML_Multi_Currency(); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - $currencies = $this->wcml->get_currencies(); |
|
| 103 | - if ( empty( $currencies ) ) { |
|
| 104 | - return; |
|
| 105 | - } |
|
| 102 | + $currencies = $this->wcml->get_currencies(); |
|
| 103 | + if ( empty( $currencies ) ) { |
|
| 104 | + return; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // Manual pricing not enabled. |
|
| 108 | - $instance = $this->wc_shipping_method->instance_settings; |
|
| 109 | - if ( ! isset( $instance['wcml_shipping_costs'] ) || 'manual' !== $instance['wcml_shipping_costs'] ) { |
|
| 110 | - return; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $currency_codes = array_keys( $currencies ); |
|
| 107 | + // Manual pricing not enabled. |
|
| 108 | + $instance = $this->wc_shipping_method->instance_settings; |
|
| 109 | + if ( ! isset( $instance['wcml_shipping_costs'] ) || 'manual' !== $instance['wcml_shipping_costs'] ) { |
|
| 110 | + return; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $currency_codes = array_keys( $currencies ); |
|
| 114 | 114 | |
| 115 | - $this->set_value_with_currency_codes( $shipping_rate, $instance, $currency_codes ); |
|
| 115 | + $this->set_value_with_currency_codes( $shipping_rate, $instance, $currency_codes ); |
|
| 116 | 116 | |
| 117 | - } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 120 | - protected function set_value_with_currency_codes( &$shipping_rate, $instance, $currency_codes ) { |
|
| 121 | - // Override. |
|
| 122 | - } |
|
| 119 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 120 | + protected function set_value_with_currency_codes( &$shipping_rate, $instance, $currency_codes ) { |
|
| 121 | + // Override. |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - public static function wcml_requirements() { |
|
| 125 | - return class_exists( 'WCML_Multi_Currency' ) |
|
| 126 | - && function_exists( 'wcml_is_multi_currency_on' ) |
|
| 127 | - && wcml_is_multi_currency_on(); |
|
| 128 | - } |
|
| 124 | + public static function wcml_requirements() { |
|
| 125 | + return class_exists( 'WCML_Multi_Currency' ) |
|
| 126 | + && function_exists( 'wcml_is_multi_currency_on' ) |
|
| 127 | + && wcml_is_multi_currency_on(); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @param WC_Shipping_Method $wc_shipping_method |
| 21 | 21 | */ |
| 22 | - public function __construct( $wc_shipping_method ) { |
|
| 22 | + public function __construct($wc_shipping_method) { |
|
| 23 | 23 | $this->wc_shipping_method = $wc_shipping_method; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -28,102 +28,102 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return Shipping_Method |
| 30 | 30 | */ |
| 31 | - public static function from_wc_shipping_method( $wc_shipping_method ) { |
|
| 31 | + public static function from_wc_shipping_method($wc_shipping_method) { |
|
| 32 | 32 | |
| 33 | - switch ( get_class( $wc_shipping_method ) ) { |
|
| 33 | + switch (get_class($wc_shipping_method)) { |
|
| 34 | 34 | case 'WC_Shipping_Local_Pickup': |
| 35 | - return new Local_Pickup_Shipping_Method( $wc_shipping_method ); |
|
| 35 | + return new Local_Pickup_Shipping_Method($wc_shipping_method); |
|
| 36 | 36 | |
| 37 | 37 | case 'WC_Shipping_Flat_Rate': |
| 38 | - return new Flat_Rate_Shipping_Method( $wc_shipping_method ); |
|
| 38 | + return new Flat_Rate_Shipping_Method($wc_shipping_method); |
|
| 39 | 39 | |
| 40 | 40 | case 'WC_Shipping_Free_Shipping': |
| 41 | - return new Free_Shipping_Shipping_Method( $wc_shipping_method ); |
|
| 41 | + return new Free_Shipping_Shipping_Method($wc_shipping_method); |
|
| 42 | 42 | |
| 43 | 43 | default: |
| 44 | - return new self( $wc_shipping_method ); |
|
| 44 | + return new self($wc_shipping_method); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 50 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 50 | + public function add_available_delivery_method(&$jsonld) { |
|
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 55 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 55 | + public function add_shipping_rate(&$offer_shipping_details) { |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - public function add_transit_time( &$shipping_delivery_time ) { |
|
| 59 | + public function add_transit_time(&$shipping_delivery_time) { |
|
| 60 | 60 | |
| 61 | 61 | $prefix = "wcsdt_transit_m{$this->wc_shipping_method->get_instance_id()}"; |
| 62 | 62 | $property = 'transitTime'; |
| 63 | 63 | |
| 64 | - $option = get_option( 'wpsso_options' ); |
|
| 64 | + $option = get_option('wpsso_options'); |
|
| 65 | 65 | |
| 66 | - if ( empty( $option[ "{$prefix}_unit_code" ] ) |
|
| 67 | - || ! isset( $option[ "{$prefix}_minimum" ] ) |
|
| 68 | - || ! isset( $option[ "{$prefix}_maximum" ] ) |
|
| 69 | - || ! is_numeric( $option[ "{$prefix}_minimum" ] ) |
|
| 70 | - || ! is_numeric( $option[ "{$prefix}_maximum" ] ) ) { |
|
| 66 | + if (empty($option["{$prefix}_unit_code"]) |
|
| 67 | + || ! isset($option["{$prefix}_minimum"]) |
|
| 68 | + || ! isset($option["{$prefix}_maximum"]) |
|
| 69 | + || ! is_numeric($option["{$prefix}_minimum"]) |
|
| 70 | + || ! is_numeric($option["{$prefix}_maximum"])) { |
|
| 71 | 71 | return; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $unit_code = $option[ "{$prefix}_unit_code" ]; |
|
| 75 | - $minimum = $option[ "{$prefix}_minimum" ]; |
|
| 76 | - $maximum = $option[ "{$prefix}_maximum" ]; |
|
| 74 | + $unit_code = $option["{$prefix}_unit_code"]; |
|
| 75 | + $minimum = $option["{$prefix}_minimum"]; |
|
| 76 | + $maximum = $option["{$prefix}_maximum"]; |
|
| 77 | 77 | |
| 78 | - if ( 'HUR' === $unit_code ) { |
|
| 79 | - $minimum = floor( $minimum / 24.0 ); |
|
| 80 | - $maximum = ceil( $maximum / 24.0 ); |
|
| 78 | + if ('HUR' === $unit_code) { |
|
| 79 | + $minimum = floor($minimum / 24.0); |
|
| 80 | + $maximum = ceil($maximum / 24.0); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $shipping_delivery_time[ $property ] = array( |
|
| 83 | + $shipping_delivery_time[$property] = array( |
|
| 84 | 84 | '@type' => 'QuantitativeValue', |
| 85 | - 'minValue' => intval( $minimum ), |
|
| 86 | - 'maxValue' => intval( $maximum ), |
|
| 85 | + 'minValue' => intval($minimum), |
|
| 86 | + 'maxValue' => intval($maximum), |
|
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - protected function change_to_manual_currency( &$shipping_rate ) { |
|
| 91 | + protected function change_to_manual_currency(&$shipping_rate) { |
|
| 92 | 92 | // WCML not available. |
| 93 | - if ( ! $this::wcml_requirements() ) { |
|
| 93 | + if ( ! $this::wcml_requirements()) { |
|
| 94 | 94 | return; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Get WCML. |
| 98 | - if ( ! isset( $this->wcml ) ) { |
|
| 98 | + if ( ! isset($this->wcml)) { |
|
| 99 | 99 | $this->wcml = new WCML_Multi_Currency(); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $currencies = $this->wcml->get_currencies(); |
| 103 | - if ( empty( $currencies ) ) { |
|
| 103 | + if (empty($currencies)) { |
|
| 104 | 104 | return; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // Manual pricing not enabled. |
| 108 | 108 | $instance = $this->wc_shipping_method->instance_settings; |
| 109 | - if ( ! isset( $instance['wcml_shipping_costs'] ) || 'manual' !== $instance['wcml_shipping_costs'] ) { |
|
| 109 | + if ( ! isset($instance['wcml_shipping_costs']) || 'manual' !== $instance['wcml_shipping_costs']) { |
|
| 110 | 110 | return; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $currency_codes = array_keys( $currencies ); |
|
| 113 | + $currency_codes = array_keys($currencies); |
|
| 114 | 114 | |
| 115 | - $this->set_value_with_currency_codes( $shipping_rate, $instance, $currency_codes ); |
|
| 115 | + $this->set_value_with_currency_codes($shipping_rate, $instance, $currency_codes); |
|
| 116 | 116 | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 120 | - protected function set_value_with_currency_codes( &$shipping_rate, $instance, $currency_codes ) { |
|
| 120 | + protected function set_value_with_currency_codes(&$shipping_rate, $instance, $currency_codes) { |
|
| 121 | 121 | // Override. |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | public static function wcml_requirements() { |
| 125 | - return class_exists( 'WCML_Multi_Currency' ) |
|
| 126 | - && function_exists( 'wcml_is_multi_currency_on' ) |
|
| 125 | + return class_exists('WCML_Multi_Currency') |
|
| 126 | + && function_exists('wcml_is_multi_currency_on') |
|
| 127 | 127 | && wcml_is_multi_currency_on(); |
| 128 | 128 | } |
| 129 | 129 | |