Completed
Push — master ( 52a8b9...e8058d )
by David
01:08
created
src/wordlift/shipping-data/class-flat-rate-shipping-method.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,44 +6,44 @@
 block discarded – undo
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'], true ) ) {
20
-			array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' );
21
-		}
19
+        if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'], true ) ) {
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
-		$description = isset( $this->wc_shipping_method->instance_settings['description'] )
32
-			? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : '';
31
+        $description = isset( $this->wc_shipping_method->instance_settings['description'] )
32
+            ? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : '';
33 33
 
34
-		$shipping_rate = array(
35
-			'@type'       => 'MonetaryAmount',
36
-			'name'        => $this->wc_shipping_method->get_title(),
37
-			'description' => $description,
38
-			'value'       => $this->wc_shipping_method->get_option( 'cost' ),
39
-			'currency'    => get_woocommerce_currency(),
40
-		);
34
+        $shipping_rate = array(
35
+            '@type'       => 'MonetaryAmount',
36
+            'name'        => $this->wc_shipping_method->get_title(),
37
+            'description' => $description,
38
+            'value'       => $this->wc_shipping_method->get_option( 'cost' ),
39
+            'currency'    => get_woocommerce_currency(),
40
+        );
41 41
 
42
-		$this->change_to_manual_currency( $shipping_rate );
42
+        $this->change_to_manual_currency( $shipping_rate );
43 43
 
44
-		$offer_shipping_details['shippingRate'][] = $shipping_rate;
44
+        $offer_shipping_details['shippingRate'][] = $shipping_rate;
45 45
 
46
-	}
46
+    }
47 47
 
48 48
 
49 49
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -6,40 +6,40 @@
 block discarded – undo
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'], true ) ) {
20
-			array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' );
19
+		if ( ! in_array('ParcelDelivery', $jsonld['availableDeliveryMethod'], true)) {
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
-		$description = isset( $this->wc_shipping_method->instance_settings['description'] )
32
-			? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : '';
31
+		$description = isset($this->wc_shipping_method->instance_settings['description'])
32
+			? wp_strip_all_tags($this->wc_shipping_method->instance_settings['description']) : '';
33 33
 
34 34
 		$shipping_rate = array(
35 35
 			'@type'       => 'MonetaryAmount',
36 36
 			'name'        => $this->wc_shipping_method->get_title(),
37 37
 			'description' => $description,
38
-			'value'       => $this->wc_shipping_method->get_option( 'cost' ),
38
+			'value'       => $this->wc_shipping_method->get_option('cost'),
39 39
 			'currency'    => get_woocommerce_currency(),
40 40
 		);
41 41
 
42
-		$this->change_to_manual_currency( $shipping_rate );
42
+		$this->change_to_manual_currency($shipping_rate);
43 43
 
44 44
 		$offer_shipping_details['shippingRate'][] = $shipping_rate;
45 45
 
Please login to merge, or discard this patch.
src/wordlift/shipping-data/class-free-shipping-shipping-method.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,43 +4,43 @@
 block discarded – undo
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 46
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,30 +4,30 @@  discard block
 block discarded – undo
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,7 +37,7 @@  discard block
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/wordlift/shipping-data/class-local-pickup-shipping-method.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -6,45 +6,45 @@
 block discarded – undo
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'], true ) ) {
20
-			array_push( $jsonld['availableDeliveryMethod'], 'OnSitePickup' );
21
-		}
19
+        if ( ! in_array( 'OnSitePickup', $jsonld['availableDeliveryMethod'], true ) ) {
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
-		$description = isset( $this->wc_shipping_method->instance_settings['description'] )
32
-			? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : '';
31
+        $description = isset( $this->wc_shipping_method->instance_settings['description'] )
32
+            ? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : '';
33 33
 
34
-		$cost = $this->wc_shipping_method->get_option( 'cost' );
34
+        $cost = $this->wc_shipping_method->get_option( 'cost' );
35 35
 
36
-		$shipping_rate = array(
37
-			'@type'       => 'MonetaryAmount',
38
-			'name'        => $this->wc_shipping_method->get_title(),
39
-			'description' => $description,
40
-			'value'       => $cost ? $cost : '0',
41
-			'currency'    => get_woocommerce_currency(),
42
-		);
36
+        $shipping_rate = array(
37
+            '@type'       => 'MonetaryAmount',
38
+            'name'        => $this->wc_shipping_method->get_title(),
39
+            'description' => $description,
40
+            'value'       => $cost ? $cost : '0',
41
+            'currency'    => get_woocommerce_currency(),
42
+        );
43 43
 
44
-		$this->change_to_manual_currency( $shipping_rate );
44
+        $this->change_to_manual_currency( $shipping_rate );
45 45
 
46
-		$offer_shipping_details['shippingRate'][] = $shipping_rate;
46
+        $offer_shipping_details['shippingRate'][] = $shipping_rate;
47 47
 
48
-	}
48
+    }
49 49
 
50 50
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -6,32 +6,32 @@  discard block
 block discarded – undo
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'], true ) ) {
20
-			array_push( $jsonld['availableDeliveryMethod'], 'OnSitePickup' );
19
+		if ( ! in_array('OnSitePickup', $jsonld['availableDeliveryMethod'], true)) {
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
-		$description = isset( $this->wc_shipping_method->instance_settings['description'] )
32
-			? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : '';
31
+		$description = isset($this->wc_shipping_method->instance_settings['description'])
32
+			? wp_strip_all_tags($this->wc_shipping_method->instance_settings['description']) : '';
33 33
 
34
-		$cost = $this->wc_shipping_method->get_option( 'cost' );
34
+		$cost = $this->wc_shipping_method->get_option('cost');
35 35
 
36 36
 		$shipping_rate = array(
37 37
 			'@type'       => 'MonetaryAmount',
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			'currency'    => get_woocommerce_currency(),
42 42
 		);
43 43
 
44
-		$this->change_to_manual_currency( $shipping_rate );
44
+		$this->change_to_manual_currency($shipping_rate);
45 45
 
46 46
 		$offer_shipping_details['shippingRate'][] = $shipping_rate;
47 47
 
Please login to merge, or discard this patch.
src/wordlift/shipping-data/class-shipping-method.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -7,105 +7,105 @@
 block discarded – undo
7 7
 
8 8
 class Shipping_Method {
9 9
 
10
-	/**
11
-	 * @var WC_Shipping_Method $wc_shipping_method
12
-	 */
13
-	protected $wc_shipping_method;
14
-
15
-	/**
16
-	 * Shipping_Method constructor.
17
-	 *
18
-	 * @param WC_Shipping_Method $wc_shipping_method
19
-	 */
20
-	public function __construct( $wc_shipping_method ) {
21
-		$this->wc_shipping_method = $wc_shipping_method;
22
-	}
23
-
24
-	/**
25
-	 * @param WC_Shipping_Method $wc_shipping_method
26
-	 *
27
-	 * @return Shipping_Method
28
-	 */
29
-	public static function from_wc_shipping_method( $wc_shipping_method ) {
30
-
31
-		switch ( get_class( $wc_shipping_method ) ) {
32
-			case 'WC_Shipping_Local_Pickup':
33
-				return new Local_Pickup_Shipping_Method( $wc_shipping_method );
34
-
35
-			case 'WC_Shipping_Flat_Rate':
36
-				return new Flat_Rate_Shipping_Method( $wc_shipping_method );
37
-
38
-			case 'WC_Shipping_Free_Shipping':
39
-				return new Free_Shipping_Shipping_Method( $wc_shipping_method );
40
-
41
-			default:
42
-				return new self( $wc_shipping_method );
43
-		}
44
-
45
-	}
46
-
47
-	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
48
-	public function add_available_delivery_method( &$jsonld ) {
49
-
50
-	}
51
-
52
-	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
53
-	public function add_shipping_rate( &$offer_shipping_details ) {
54
-
55
-	}
56
-
57
-	public function add_transit_time( &$shipping_delivery_time ) {
58
-
59
-		$prefix   = "wcsdt_transit_m{$this->wc_shipping_method->get_instance_id()}";
60
-		$property = 'transitTime';
61
-
62
-		$option = get_option( 'wpsso_options' );
63
-
64
-		if ( empty( $option[ "{$prefix}_unit_code" ] )
65
-			 || ! isset( $option[ "{$prefix}_minimum" ] )
66
-			 || ! isset( $option[ "{$prefix}_maximum" ] )
67
-			 || ! is_numeric( $option[ "{$prefix}_minimum" ] )
68
-			 || ! is_numeric( $option[ "{$prefix}_maximum" ] ) ) {
69
-			return;
70
-		}
71
-
72
-		$unit_code = $option[ "{$prefix}_unit_code" ];
73
-		$minimum   = $option[ "{$prefix}_minimum" ];
74
-		$maximum   = $option[ "{$prefix}_maximum" ];
75
-
76
-		if ( 'HUR' === $unit_code ) {
77
-			$minimum = floor( $minimum / 24.0 );
78
-			$maximum = ceil( $maximum / 24.0 );
79
-		}
80
-
81
-		$shipping_delivery_time[ $property ] = array(
82
-			'@type'    => 'QuantitativeValue',
83
-			'minValue' => intval( $minimum ),
84
-			'maxValue' => intval( $maximum ),
85
-		);
86
-
87
-	}
88
-
89
-	protected function change_to_manual_currency( &$shipping_rate ) {
90
-		// WCML not available.
91
-		if ( ! class_exists( 'WCML\Multicurrency\Shipping\ShippingModeProvider' ) ) {
92
-			return;
93
-		}
94
-
95
-		// Manual pricing not enabled.
96
-		if ( ! ShippingModeProvider::get( $this->wc_shipping_method->id )->isManualPricingEnabled( $this->wc_shipping_method ) ) {
97
-			return;
98
-		}
99
-
100
-		// Get the first manual price.
101
-		foreach ( $this->wc_shipping_method->instance_settings as $key => $value ) {
102
-			if ( preg_match( '@^cost_(\w{3})$@', $key, $matches ) ) {
103
-				$shipping_rate['value']    = $value;
104
-				$shipping_rate['currency'] = $matches[1];
105
-
106
-				return;
107
-			}
108
-		}
109
-	}
10
+    /**
11
+     * @var WC_Shipping_Method $wc_shipping_method
12
+     */
13
+    protected $wc_shipping_method;
14
+
15
+    /**
16
+     * Shipping_Method constructor.
17
+     *
18
+     * @param WC_Shipping_Method $wc_shipping_method
19
+     */
20
+    public function __construct( $wc_shipping_method ) {
21
+        $this->wc_shipping_method = $wc_shipping_method;
22
+    }
23
+
24
+    /**
25
+     * @param WC_Shipping_Method $wc_shipping_method
26
+     *
27
+     * @return Shipping_Method
28
+     */
29
+    public static function from_wc_shipping_method( $wc_shipping_method ) {
30
+
31
+        switch ( get_class( $wc_shipping_method ) ) {
32
+            case 'WC_Shipping_Local_Pickup':
33
+                return new Local_Pickup_Shipping_Method( $wc_shipping_method );
34
+
35
+            case 'WC_Shipping_Flat_Rate':
36
+                return new Flat_Rate_Shipping_Method( $wc_shipping_method );
37
+
38
+            case 'WC_Shipping_Free_Shipping':
39
+                return new Free_Shipping_Shipping_Method( $wc_shipping_method );
40
+
41
+            default:
42
+                return new self( $wc_shipping_method );
43
+        }
44
+
45
+    }
46
+
47
+    // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
48
+    public function add_available_delivery_method( &$jsonld ) {
49
+
50
+    }
51
+
52
+    // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
53
+    public function add_shipping_rate( &$offer_shipping_details ) {
54
+
55
+    }
56
+
57
+    public function add_transit_time( &$shipping_delivery_time ) {
58
+
59
+        $prefix   = "wcsdt_transit_m{$this->wc_shipping_method->get_instance_id()}";
60
+        $property = 'transitTime';
61
+
62
+        $option = get_option( 'wpsso_options' );
63
+
64
+        if ( empty( $option[ "{$prefix}_unit_code" ] )
65
+             || ! isset( $option[ "{$prefix}_minimum" ] )
66
+             || ! isset( $option[ "{$prefix}_maximum" ] )
67
+             || ! is_numeric( $option[ "{$prefix}_minimum" ] )
68
+             || ! is_numeric( $option[ "{$prefix}_maximum" ] ) ) {
69
+            return;
70
+        }
71
+
72
+        $unit_code = $option[ "{$prefix}_unit_code" ];
73
+        $minimum   = $option[ "{$prefix}_minimum" ];
74
+        $maximum   = $option[ "{$prefix}_maximum" ];
75
+
76
+        if ( 'HUR' === $unit_code ) {
77
+            $minimum = floor( $minimum / 24.0 );
78
+            $maximum = ceil( $maximum / 24.0 );
79
+        }
80
+
81
+        $shipping_delivery_time[ $property ] = array(
82
+            '@type'    => 'QuantitativeValue',
83
+            'minValue' => intval( $minimum ),
84
+            'maxValue' => intval( $maximum ),
85
+        );
86
+
87
+    }
88
+
89
+    protected function change_to_manual_currency( &$shipping_rate ) {
90
+        // WCML not available.
91
+        if ( ! class_exists( 'WCML\Multicurrency\Shipping\ShippingModeProvider' ) ) {
92
+            return;
93
+        }
94
+
95
+        // Manual pricing not enabled.
96
+        if ( ! ShippingModeProvider::get( $this->wc_shipping_method->id )->isManualPricingEnabled( $this->wc_shipping_method ) ) {
97
+            return;
98
+        }
99
+
100
+        // Get the first manual price.
101
+        foreach ( $this->wc_shipping_method->instance_settings as $key => $value ) {
102
+            if ( preg_match( '@^cost_(\w{3})$@', $key, $matches ) ) {
103
+                $shipping_rate['value']    = $value;
104
+                $shipping_rate['currency'] = $matches[1];
105
+
106
+                return;
107
+            }
108
+        }
109
+    }
110 110
 
111 111
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @param WC_Shipping_Method $wc_shipping_method
19 19
 	 */
20
-	public function __construct( $wc_shipping_method ) {
20
+	public function __construct($wc_shipping_method) {
21 21
 		$this->wc_shipping_method = $wc_shipping_method;
22 22
 	}
23 23
 
@@ -26,80 +26,80 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return Shipping_Method
28 28
 	 */
29
-	public static function from_wc_shipping_method( $wc_shipping_method ) {
29
+	public static function from_wc_shipping_method($wc_shipping_method) {
30 30
 
31
-		switch ( get_class( $wc_shipping_method ) ) {
31
+		switch (get_class($wc_shipping_method)) {
32 32
 			case 'WC_Shipping_Local_Pickup':
33
-				return new Local_Pickup_Shipping_Method( $wc_shipping_method );
33
+				return new Local_Pickup_Shipping_Method($wc_shipping_method);
34 34
 
35 35
 			case 'WC_Shipping_Flat_Rate':
36
-				return new Flat_Rate_Shipping_Method( $wc_shipping_method );
36
+				return new Flat_Rate_Shipping_Method($wc_shipping_method);
37 37
 
38 38
 			case 'WC_Shipping_Free_Shipping':
39
-				return new Free_Shipping_Shipping_Method( $wc_shipping_method );
39
+				return new Free_Shipping_Shipping_Method($wc_shipping_method);
40 40
 
41 41
 			default:
42
-				return new self( $wc_shipping_method );
42
+				return new self($wc_shipping_method);
43 43
 		}
44 44
 
45 45
 	}
46 46
 
47 47
 	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
48
-	public function add_available_delivery_method( &$jsonld ) {
48
+	public function add_available_delivery_method(&$jsonld) {
49 49
 
50 50
 	}
51 51
 
52 52
 	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
53
-	public function add_shipping_rate( &$offer_shipping_details ) {
53
+	public function add_shipping_rate(&$offer_shipping_details) {
54 54
 
55 55
 	}
56 56
 
57
-	public function add_transit_time( &$shipping_delivery_time ) {
57
+	public function add_transit_time(&$shipping_delivery_time) {
58 58
 
59 59
 		$prefix   = "wcsdt_transit_m{$this->wc_shipping_method->get_instance_id()}";
60 60
 		$property = 'transitTime';
61 61
 
62
-		$option = get_option( 'wpsso_options' );
62
+		$option = get_option('wpsso_options');
63 63
 
64
-		if ( empty( $option[ "{$prefix}_unit_code" ] )
65
-			 || ! isset( $option[ "{$prefix}_minimum" ] )
66
-			 || ! isset( $option[ "{$prefix}_maximum" ] )
67
-			 || ! is_numeric( $option[ "{$prefix}_minimum" ] )
68
-			 || ! is_numeric( $option[ "{$prefix}_maximum" ] ) ) {
64
+		if (empty($option["{$prefix}_unit_code"])
65
+			 || ! isset($option["{$prefix}_minimum"])
66
+			 || ! isset($option["{$prefix}_maximum"])
67
+			 || ! is_numeric($option["{$prefix}_minimum"])
68
+			 || ! is_numeric($option["{$prefix}_maximum"])) {
69 69
 			return;
70 70
 		}
71 71
 
72
-		$unit_code = $option[ "{$prefix}_unit_code" ];
73
-		$minimum   = $option[ "{$prefix}_minimum" ];
74
-		$maximum   = $option[ "{$prefix}_maximum" ];
72
+		$unit_code = $option["{$prefix}_unit_code"];
73
+		$minimum   = $option["{$prefix}_minimum"];
74
+		$maximum   = $option["{$prefix}_maximum"];
75 75
 
76
-		if ( 'HUR' === $unit_code ) {
77
-			$minimum = floor( $minimum / 24.0 );
78
-			$maximum = ceil( $maximum / 24.0 );
76
+		if ('HUR' === $unit_code) {
77
+			$minimum = floor($minimum / 24.0);
78
+			$maximum = ceil($maximum / 24.0);
79 79
 		}
80 80
 
81
-		$shipping_delivery_time[ $property ] = array(
81
+		$shipping_delivery_time[$property] = array(
82 82
 			'@type'    => 'QuantitativeValue',
83
-			'minValue' => intval( $minimum ),
84
-			'maxValue' => intval( $maximum ),
83
+			'minValue' => intval($minimum),
84
+			'maxValue' => intval($maximum),
85 85
 		);
86 86
 
87 87
 	}
88 88
 
89
-	protected function change_to_manual_currency( &$shipping_rate ) {
89
+	protected function change_to_manual_currency(&$shipping_rate) {
90 90
 		// WCML not available.
91
-		if ( ! class_exists( 'WCML\Multicurrency\Shipping\ShippingModeProvider' ) ) {
91
+		if ( ! class_exists('WCML\Multicurrency\Shipping\ShippingModeProvider')) {
92 92
 			return;
93 93
 		}
94 94
 
95 95
 		// Manual pricing not enabled.
96
-		if ( ! ShippingModeProvider::get( $this->wc_shipping_method->id )->isManualPricingEnabled( $this->wc_shipping_method ) ) {
96
+		if ( ! ShippingModeProvider::get($this->wc_shipping_method->id)->isManualPricingEnabled($this->wc_shipping_method)) {
97 97
 			return;
98 98
 		}
99 99
 
100 100
 		// Get the first manual price.
101
-		foreach ( $this->wc_shipping_method->instance_settings as $key => $value ) {
102
-			if ( preg_match( '@^cost_(\w{3})$@', $key, $matches ) ) {
101
+		foreach ($this->wc_shipping_method->instance_settings as $key => $value) {
102
+			if (preg_match('@^cost_(\w{3})$@', $key, $matches)) {
103 103
 				$shipping_rate['value']    = $value;
104 104
 				$shipping_rate['currency'] = $matches[1];
105 105
 
Please login to merge, or discard this patch.