Completed
Pull Request — develop (#1347)
by David
04:57 queued 01:46
created
src/wordlift/shipping-data/class-shipping-zones.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -8,81 +8,81 @@
 block discarded – undo
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
-	/**
56
-	 * @param array $jsonld
57
-	 * @param Product $product
58
-	 */
59
-	public function add_offer_shipping_details( &$jsonld, $product ) {
55
+    /**
56
+     * @param array $jsonld
57
+     * @param Product $product
58
+     */
59
+    public function add_offer_shipping_details( &$jsonld, $product ) {
60 60
 
61
-		$this->load_zones();
61
+        $this->load_zones();
62 62
 
63
-		foreach ( $this->zones as $zone ) {
64
-			$zone->add_offer_shipping_details( $jsonld, $product );
65
-		}
63
+        foreach ( $this->zones as $zone ) {
64
+            $zone->add_offer_shipping_details( $jsonld, $product );
65
+        }
66 66
 
67
-	}
67
+    }
68 68
 
69
-	private function get_country_codes( $wc_shipping_zones ) {
70
-		$countries = array();
69
+    private function get_country_codes( $wc_shipping_zones ) {
70
+        $countries = array();
71 71
 
72
-		foreach ( $wc_shipping_zones as $wc_shipping_zone ) {
73
-			if ( ! isset( $wc_shipping_zone->type )
74
-			     || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) {
75
-				continue;
76
-			}
72
+        foreach ( $wc_shipping_zones as $wc_shipping_zone ) {
73
+            if ( ! isset( $wc_shipping_zone->type )
74
+                 || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) {
75
+                continue;
76
+            }
77 77
 
78
-			$country = substr( $wc_shipping_zone->code, 0, 2 );
78
+            $country = substr( $wc_shipping_zone->code, 0, 2 );
79 79
 
80
-			if ( ! in_array( $country, $countries ) ) {
81
-				$countries[] = $country;
82
-			}
83
-		}
80
+            if ( ! in_array( $country, $countries ) ) {
81
+                $countries[] = $country;
82
+            }
83
+        }
84 84
 
85
-		return $countries;
86
-	}
85
+        return $countries;
86
+    }
87 87
 
88 88
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -19,21 +19,21 @@  discard block
 block discarded – undo
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,12 +42,12 @@  discard block
 block discarded – undo
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
 	}
@@ -56,28 +56,28 @@  discard block
 block discarded – undo
56 56
 	 * @param array $jsonld
57 57
 	 * @param Product $product
58 58
 	 */
59
-	public function add_offer_shipping_details( &$jsonld, $product ) {
59
+	public function add_offer_shipping_details(&$jsonld, $product) {
60 60
 
61 61
 		$this->load_zones();
62 62
 
63
-		foreach ( $this->zones as $zone ) {
64
-			$zone->add_offer_shipping_details( $jsonld, $product );
63
+		foreach ($this->zones as $zone) {
64
+			$zone->add_offer_shipping_details($jsonld, $product);
65 65
 		}
66 66
 
67 67
 	}
68 68
 
69
-	private function get_country_codes( $wc_shipping_zones ) {
69
+	private function get_country_codes($wc_shipping_zones) {
70 70
 		$countries = array();
71 71
 
72
-		foreach ( $wc_shipping_zones as $wc_shipping_zone ) {
73
-			if ( ! isset( $wc_shipping_zone->type )
74
-			     || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) {
72
+		foreach ($wc_shipping_zones as $wc_shipping_zone) {
73
+			if ( ! isset($wc_shipping_zone->type)
74
+			     || ('country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type)) {
75 75
 				continue;
76 76
 			}
77 77
 
78
-			$country = substr( $wc_shipping_zone->code, 0, 2 );
78
+			$country = substr($wc_shipping_zone->code, 0, 2);
79 79
 
80
-			if ( ! in_array( $country, $countries ) ) {
80
+			if ( ! in_array($country, $countries)) {
81 81
 				$countries[] = $country;
82 82
 			}
83 83
 		}
Please login to merge, or discard this patch.
src/wordlift/shipping-data/class-offer-structured-data.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,43 +4,43 @@
 block discarded – undo
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
-		$product = new Product( $post_id );
36
+        $product = new Product( $post_id );
37 37
 
38
-		foreach ( $jsonld['offers'] as &$offer ) {
39
-			$this->shipping_zones->add_available_delivery_method( $offer );
40
-			$this->shipping_zones->add_offer_shipping_details( $offer, $product );
41
-		}
38
+        foreach ( $jsonld['offers'] as &$offer ) {
39
+            $this->shipping_zones->add_available_delivery_method( $offer );
40
+            $this->shipping_zones->add_offer_shipping_details( $offer, $product );
41
+        }
42 42
 
43
-		return $jsonld;
44
-	}
43
+        return $jsonld;
44
+    }
45 45
 
46 46
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@
 block discarded – undo
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
-		$product = new Product( $post_id );
36
+		$product = new Product($post_id);
37 37
 
38
-		foreach ( $jsonld['offers'] as &$offer ) {
39
-			$this->shipping_zones->add_available_delivery_method( $offer );
40
-			$this->shipping_zones->add_offer_shipping_details( $offer, $product );
38
+		foreach ($jsonld['offers'] as &$offer) {
39
+			$this->shipping_zones->add_available_delivery_method($offer);
40
+			$this->shipping_zones->add_offer_shipping_details($offer, $product);
41 41
 		}
42 42
 
43 43
 		return $jsonld;
Please login to merge, or discard this patch.
src/wordlift/shipping-data/class-product.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -4,59 +4,59 @@
 block discarded – undo
4 4
 
5 5
 class Product {
6 6
 
7
-	/**
8
-	 * @var false|\WC_Product|null
9
-	 */
10
-	private $wc_product;
7
+    /**
8
+     * @var false|\WC_Product|null
9
+     */
10
+    private $wc_product;
11 11
 
12
-	/**
13
-	 * Product constructor.
14
-	 *
15
-	 * @param $post_id
16
-	 */
17
-	public function __construct( $post_id ) {
12
+    /**
13
+     * Product constructor.
14
+     *
15
+     * @param $post_id
16
+     */
17
+    public function __construct( $post_id ) {
18 18
 
19
-		$this->wc_product = wc_get_product( $post_id );
19
+        $this->wc_product = wc_get_product( $post_id );
20 20
 
21
-	}
21
+    }
22 22
 
23
-	public function add_handling_time( &$shipping_delivery_time ) {
23
+    public function add_handling_time( &$shipping_delivery_time ) {
24 24
 
25
-		// Bail out if there's no product.
26
-		if ( empty( $this->wc_product ) ) {
27
-			return;
28
-		}
25
+        // Bail out if there's no product.
26
+        if ( empty( $this->wc_product ) ) {
27
+            return;
28
+        }
29 29
 
30
-		$shipping_class_id = $this->wc_product->get_shipping_class_id();
30
+        $shipping_class_id = $this->wc_product->get_shipping_class_id();
31 31
 
32
-		$option = get_option( 'wpsso_options' );
32
+        $option = get_option( 'wpsso_options' );
33 33
 
34
-		if ( empty( $option["wcsdt_handling_c{$shipping_class_id}_unit_code"] )
35
-		     || empty( $option["wcsdt_handling_c{$shipping_class_id}_minimum"] )
36
-		     || empty( $option["wcsdt_handling_c{$shipping_class_id}_maximum"] ) ) {
37
-			return;
38
-		}
34
+        if ( empty( $option["wcsdt_handling_c{$shipping_class_id}_unit_code"] )
35
+             || empty( $option["wcsdt_handling_c{$shipping_class_id}_minimum"] )
36
+             || empty( $option["wcsdt_handling_c{$shipping_class_id}_maximum"] ) ) {
37
+            return;
38
+        }
39 39
 
40
-		$unit_code = $option["wcsdt_handling_c{$shipping_class_id}_unit_code"];
41
-		$minimum   = $option["wcsdt_handling_c{$shipping_class_id}_minimum"];
42
-		$maximum   = $option["wcsdt_handling_c{$shipping_class_id}_maximum"];
40
+        $unit_code = $option["wcsdt_handling_c{$shipping_class_id}_unit_code"];
41
+        $minimum   = $option["wcsdt_handling_c{$shipping_class_id}_minimum"];
42
+        $maximum   = $option["wcsdt_handling_c{$shipping_class_id}_maximum"];
43 43
 
44
-		if ( 'HUR' === $unit_code ) {
45
-			$minimum = floor( $minimum / 24.0 );
46
-			$maximum = ceil( $maximum / 24.0 );
47
-		}
44
+        if ( 'HUR' === $unit_code ) {
45
+            $minimum = floor( $minimum / 24.0 );
46
+            $maximum = ceil( $maximum / 24.0 );
47
+        }
48 48
 
49
-		$shipping_delivery_time['handlingTime'] = array(
50
-			'@type'    => 'QuantitativeValue',
51
-			'minValue' => $minimum,
52
-			'maxValue' => $maximum,
53
-		);
49
+        $shipping_delivery_time['handlingTime'] = array(
50
+            '@type'    => 'QuantitativeValue',
51
+            'minValue' => $minimum,
52
+            'maxValue' => $maximum,
53
+        );
54 54
 
55
-	}
55
+    }
56 56
 
57
-	private function get_handling_time() {
57
+    private function get_handling_time() {
58 58
 
59 59
 
60
-	}
60
+    }
61 61
 
62 62
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,26 +14,26 @@  discard block
 block discarded – undo
14 14
 	 *
15 15
 	 * @param $post_id
16 16
 	 */
17
-	public function __construct( $post_id ) {
17
+	public function __construct($post_id) {
18 18
 
19
-		$this->wc_product = wc_get_product( $post_id );
19
+		$this->wc_product = wc_get_product($post_id);
20 20
 
21 21
 	}
22 22
 
23
-	public function add_handling_time( &$shipping_delivery_time ) {
23
+	public function add_handling_time(&$shipping_delivery_time) {
24 24
 
25 25
 		// Bail out if there's no product.
26
-		if ( empty( $this->wc_product ) ) {
26
+		if (empty($this->wc_product)) {
27 27
 			return;
28 28
 		}
29 29
 
30 30
 		$shipping_class_id = $this->wc_product->get_shipping_class_id();
31 31
 
32
-		$option = get_option( 'wpsso_options' );
32
+		$option = get_option('wpsso_options');
33 33
 
34
-		if ( empty( $option["wcsdt_handling_c{$shipping_class_id}_unit_code"] )
35
-		     || empty( $option["wcsdt_handling_c{$shipping_class_id}_minimum"] )
36
-		     || empty( $option["wcsdt_handling_c{$shipping_class_id}_maximum"] ) ) {
34
+		if (empty($option["wcsdt_handling_c{$shipping_class_id}_unit_code"])
35
+		     || empty($option["wcsdt_handling_c{$shipping_class_id}_minimum"])
36
+		     || empty($option["wcsdt_handling_c{$shipping_class_id}_maximum"])) {
37 37
 			return;
38 38
 		}
39 39
 
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 		$minimum   = $option["wcsdt_handling_c{$shipping_class_id}_minimum"];
42 42
 		$maximum   = $option["wcsdt_handling_c{$shipping_class_id}_maximum"];
43 43
 
44
-		if ( 'HUR' === $unit_code ) {
45
-			$minimum = floor( $minimum / 24.0 );
46
-			$maximum = ceil( $maximum / 24.0 );
44
+		if ('HUR' === $unit_code) {
45
+			$minimum = floor($minimum / 24.0);
46
+			$maximum = ceil($maximum / 24.0);
47 47
 		}
48 48
 
49 49
 		$shipping_delivery_time['handlingTime'] = array(
Please login to merge, or discard this patch.
src/wordlift/shipping-data/class-shipping-method.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -8,79 +8,79 @@
 block discarded – undo
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
-	public function add_transit_time( &$shipping_delivery_time ) {
56
+    public function add_transit_time( &$shipping_delivery_time ) {
57 57
 
58
-		$prefix   = "wcsdt_transit_m{$this->wc_shipping_method->get_instance_id()}";
59
-		$property = 'transitTime';
58
+        $prefix   = "wcsdt_transit_m{$this->wc_shipping_method->get_instance_id()}";
59
+        $property = 'transitTime';
60 60
 
61
-		$option = get_option( 'wpsso_options' );
61
+        $option = get_option( 'wpsso_options' );
62 62
 
63
-		if ( empty( $option["{$prefix}_unit_code"] )
64
-		     || empty( $option["{$prefix}_minimum"] )
65
-		     || empty( $option["{$prefix}_maximum"] ) ) {
66
-			return;
67
-		}
63
+        if ( empty( $option["{$prefix}_unit_code"] )
64
+             || empty( $option["{$prefix}_minimum"] )
65
+             || empty( $option["{$prefix}_maximum"] ) ) {
66
+            return;
67
+        }
68 68
 
69
-		$unit_code = $option["{$prefix}_unit_code"];
70
-		$minimum   = $option["{$prefix}_minimum"];
71
-		$maximum   = $option["{$prefix}_maximum"];
69
+        $unit_code = $option["{$prefix}_unit_code"];
70
+        $minimum   = $option["{$prefix}_minimum"];
71
+        $maximum   = $option["{$prefix}_maximum"];
72 72
 
73
-		if ( 'HUR' === $unit_code ) {
74
-			$minimum = floor( $minimum / 24.0 );
75
-			$maximum = ceil( $maximum / 24.0 );
76
-		}
73
+        if ( 'HUR' === $unit_code ) {
74
+            $minimum = floor( $minimum / 24.0 );
75
+            $maximum = ceil( $maximum / 24.0 );
76
+        }
77 77
 
78
-		$shipping_delivery_time[ $property ] = array(
79
-			'@type'    => 'QuantitativeValue',
80
-			'minValue' => intval( $minimum ),
81
-			'maxValue' => intval( $maximum ),
82
-		);
78
+        $shipping_delivery_time[ $property ] = array(
79
+            '@type'    => 'QuantitativeValue',
80
+            'minValue' => intval( $minimum ),
81
+            'maxValue' => intval( $maximum ),
82
+        );
83 83
 
84
-	}
84
+    }
85 85
 
86 86
 }
87 87
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
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,42 +27,42 @@  discard block
 block discarded – undo
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
 
56
-	public function add_transit_time( &$shipping_delivery_time ) {
56
+	public function add_transit_time(&$shipping_delivery_time) {
57 57
 
58 58
 		$prefix   = "wcsdt_transit_m{$this->wc_shipping_method->get_instance_id()}";
59 59
 		$property = 'transitTime';
60 60
 
61
-		$option = get_option( 'wpsso_options' );
61
+		$option = get_option('wpsso_options');
62 62
 
63
-		if ( empty( $option["{$prefix}_unit_code"] )
64
-		     || empty( $option["{$prefix}_minimum"] )
65
-		     || empty( $option["{$prefix}_maximum"] ) ) {
63
+		if (empty($option["{$prefix}_unit_code"])
64
+		     || empty($option["{$prefix}_minimum"])
65
+		     || empty($option["{$prefix}_maximum"])) {
66 66
 			return;
67 67
 		}
68 68
 
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
 		$minimum   = $option["{$prefix}_minimum"];
71 71
 		$maximum   = $option["{$prefix}_maximum"];
72 72
 
73
-		if ( 'HUR' === $unit_code ) {
74
-			$minimum = floor( $minimum / 24.0 );
75
-			$maximum = ceil( $maximum / 24.0 );
73
+		if ('HUR' === $unit_code) {
74
+			$minimum = floor($minimum / 24.0);
75
+			$maximum = ceil($maximum / 24.0);
76 76
 		}
77 77
 
78
-		$shipping_delivery_time[ $property ] = array(
78
+		$shipping_delivery_time[$property] = array(
79 79
 			'@type'    => 'QuantitativeValue',
80
-			'minValue' => intval( $minimum ),
81
-			'maxValue' => intval( $maximum ),
80
+			'minValue' => intval($minimum),
81
+			'maxValue' => intval($maximum),
82 82
 		);
83 83
 
84 84
 	}
Please login to merge, or discard this patch.
src/wordlift/shipping-data/index.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@
 block discarded – undo
9 9
      || ! class_exists( '\WC_Shipping_Method' )
10 10
      || ! function_exists( 'get_woocommerce_currency' )
11 11
      || ! function_exists( 'wc_get_product' ) ) {
12
-	return;
12
+    return;
13 13
 }
14 14
 
15 15
 if ( ! apply_filters( 'wl_feature__enable__shipping-sd', false ) ) {
16
-	return;
16
+    return;
17 17
 }
18 18
 
19 19
 $shipping_zones        = new Shipping_Zones();
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@
 block discarded – undo
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' )
11
-     || ! function_exists( 'wc_get_product' ) ) {
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
+     || ! function_exists('wc_get_product')) {
12 12
 	return;
13 13
 }
14 14
 
15
-if ( ! apply_filters( 'wl_feature__enable__shipping-sd', false ) ) {
15
+if ( ! apply_filters('wl_feature__enable__shipping-sd', false)) {
16 16
 	return;
17 17
 }
18 18
 
19 19
 $shipping_zones        = new Shipping_Zones();
20
-$offer_structured_data = new Offer_Structured_Data( $shipping_zones );
20
+$offer_structured_data = new Offer_Structured_Data($shipping_zones);
Please login to merge, or discard this patch.
src/wordlift/shipping-data/class-shipping-zone.php 2 patches
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -10,140 +10,140 @@  discard block
 block discarded – undo
10 10
 
11 11
 class Shipping_Zone {
12 12
 
13
-	/**
14
-	 * @var WC_Shipping_Zone
15
-	 */
16
-	private $wc_shipping_zone;
13
+    /**
14
+     * @var WC_Shipping_Zone
15
+     */
16
+    private $wc_shipping_zone;
17 17
 
18
-	/**
19
-	 * @var Shipping_Method[]
20
-	 */
21
-	private $methods;
18
+    /**
19
+     * @var Shipping_Method[]
20
+     */
21
+    private $methods;
22 22
 
23
-	/**
24
-	 * @var string
25
-	 */
26
-	private $country_code;
23
+    /**
24
+     * @var string
25
+     */
26
+    private $country_code;
27 27
 
28
-	/**
29
-	 * @var string[]
30
-	 */
31
-	private $regions = array();
28
+    /**
29
+     * @var string[]
30
+     */
31
+    private $regions = array();
32 32
 
33
-	/**
34
-	 * @var string[]
35
-	 */
36
-	private $postal_codes = array();
33
+    /**
34
+     * @var string[]
35
+     */
36
+    private $postal_codes = array();
37 37
 
38
-	/**
39
-	 * @var string[]
40
-	 */
41
-	private $postal_code_prefixes = array();
38
+    /**
39
+     * @var string[]
40
+     */
41
+    private $postal_code_prefixes = array();
42 42
 
43
-	/**
44
-	 * @var string[]
45
-	 */
46
-	private $postal_code_ranges = array();
43
+    /**
44
+     * @var string[]
45
+     */
46
+    private $postal_code_ranges = array();
47 47
 
48
-	/**
49
-	 * Shipping_Zone constructor.
50
-	 *
51
-	 * @param WC_Shipping_Zone $wc_shipping_zone
52
-	 * @param string $country_code
53
-	 */
54
-	public function __construct( $wc_shipping_zone, $country_code ) {
48
+    /**
49
+     * Shipping_Zone constructor.
50
+     *
51
+     * @param WC_Shipping_Zone $wc_shipping_zone
52
+     * @param string $country_code
53
+     */
54
+    public function __construct( $wc_shipping_zone, $country_code ) {
55 55
 
56
-		$this->wc_shipping_zone = $wc_shipping_zone;
57
-		$this->country_code     = $country_code;
56
+        $this->wc_shipping_zone = $wc_shipping_zone;
57
+        $this->country_code     = $country_code;
58 58
 
59
-		$this->load_zone_locations();
59
+        $this->load_zone_locations();
60 60
 
61
-	}
61
+    }
62 62
 
63
-	private function load_zone_locations() {
63
+    private function load_zone_locations() {
64 64
 
65
-		$this->regions              = array();
66
-		$this->postal_codes         = array();
67
-		$this->postal_code_prefixes = array();
68
-		$this->postal_code_ranges   = array();
65
+        $this->regions              = array();
66
+        $this->postal_codes         = array();
67
+        $this->postal_code_prefixes = array();
68
+        $this->postal_code_ranges   = array();
69 69
 
70
-		// Bail out if country code isn't set.
71
-		if ( ! isset( $this->country_code ) ) {
72
-			return;
73
-		}
70
+        // Bail out if country code isn't set.
71
+        if ( ! isset( $this->country_code ) ) {
72
+            return;
73
+        }
74 74
 
75
-		foreach ( $this->wc_shipping_zone->get_zone_locations() as $zone_location ) {
76
-			switch ( $zone_location->type ) {
77
-				case 'state':
78
-					if ( 0 === strpos( $zone_location->code, "$this->country_code:" ) ) {
79
-						$this->regions[] = substr( $zone_location->code, 3 );
80
-					}
75
+        foreach ( $this->wc_shipping_zone->get_zone_locations() as $zone_location ) {
76
+            switch ( $zone_location->type ) {
77
+                case 'state':
78
+                    if ( 0 === strpos( $zone_location->code, "$this->country_code:" ) ) {
79
+                        $this->regions[] = substr( $zone_location->code, 3 );
80
+                    }
81 81
 
82
-					break;
82
+                    break;
83 83
 
84
-				case 'postcode':
85
-					if ( '*' === substr( $zone_location->code, - 1 ) ) {
86
-						$this->postal_code_prefixes[] = $zone_location->code;
87
-					} else if ( - 1 < strpos( $zone_location->code, '...' ) ) {
88
-						$this->postal_code_ranges[] = $zone_location->code;
89
-					} else {
90
-						$this->postal_codes[] = $zone_location->code;
91
-					}
84
+                case 'postcode':
85
+                    if ( '*' === substr( $zone_location->code, - 1 ) ) {
86
+                        $this->postal_code_prefixes[] = $zone_location->code;
87
+                    } else if ( - 1 < strpos( $zone_location->code, '...' ) ) {
88
+                        $this->postal_code_ranges[] = $zone_location->code;
89
+                    } else {
90
+                        $this->postal_codes[] = $zone_location->code;
91
+                    }
92 92
 
93
-					break;
93
+                    break;
94 94
 
95
-				default:
96
-			}
97
-		}
95
+                default:
96
+            }
97
+        }
98 98
 
99
-	}
99
+    }
100 100
 
101
-	private function load_methods() {
101
+    private function load_methods() {
102 102
 
103
-		$this->methods = array_map( 'Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method',
104
-			$this->wc_shipping_zone->get_shipping_methods( true ) );
103
+        $this->methods = array_map( 'Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method',
104
+            $this->wc_shipping_zone->get_shipping_methods( true ) );
105 105
 
106
-	}
106
+    }
107 107
 
108
-	public function add_available_delivery_method( &$jsonld ) {
108
+    public function add_available_delivery_method( &$jsonld ) {
109 109
 
110
-		$this->load_methods();
110
+        $this->load_methods();
111 111
 
112
-		foreach ( $this->methods as $method ) {
113
-			$method->add_available_delivery_method( $jsonld );
114
-		}
112
+        foreach ( $this->methods as $method ) {
113
+            $method->add_available_delivery_method( $jsonld );
114
+        }
115 115
 
116
-	}
116
+    }
117 117
 
118
-	/**
119
-	 * @param array $jsonld
120
-	 * @param Product $product
121
-	 */
122
-	public function add_offer_shipping_details( &$jsonld, $product ) {
118
+    /**
119
+     * @param array $jsonld
120
+     * @param Product $product
121
+     */
122
+    public function add_offer_shipping_details( &$jsonld, $product ) {
123 123
 
124
-		$this->load_methods();
124
+        $this->load_methods();
125 125
 
126
-		// Ignore the default zone if no methods are configured.
127
-		if ( 0 === $this->wc_shipping_zone->get_id() && 0 === count( $this->methods ) ) {
128
-			return;
129
-		}
126
+        // Ignore the default zone if no methods are configured.
127
+        if ( 0 === $this->wc_shipping_zone->get_id() && 0 === count( $this->methods ) ) {
128
+            return;
129
+        }
130 130
 
131
-		$this->make_sure_shipping_details_exists_and_it_is_an_array( $jsonld );
131
+        $this->make_sure_shipping_details_exists_and_it_is_an_array( $jsonld );
132 132
 
133
-		if ( empty( $this->methods ) ) {
134
-			$this->add_shipping_details_with_shipping_method( $jsonld, $product );
135
-		} else {
136
-			foreach ( $this->methods as $method ) {
137
-				$this->add_shipping_details_with_shipping_method( $jsonld, $product, $method );
138
-			}
139
-		}
133
+        if ( empty( $this->methods ) ) {
134
+            $this->add_shipping_details_with_shipping_method( $jsonld, $product );
135
+        } else {
136
+            foreach ( $this->methods as $method ) {
137
+                $this->add_shipping_details_with_shipping_method( $jsonld, $product, $method );
138
+            }
139
+        }
140 140
 
141
-	}
141
+    }
142 142
 
143
-	/**
144
-	 * @param array $jsonld
145
-	 * @param Product $product
146
-	 */
143
+    /**
144
+     * @param array $jsonld
145
+     * @param Product $product
146
+     */
147 147
 //	private function add_shipping_details_when_no_shipping_methods( &$jsonld, $product ) {
148 148
 //
149 149
 //		$offer_shipping_details = array( '@type' => 'OfferShippingDetails', );
@@ -166,177 +166,177 @@  discard block
 block discarded – undo
166 166
 //
167 167
 //	}
168 168
 
169
-	/**
170
-	 * @param array $jsonld
171
-	 * @param Product $product
172
-	 * @param Shipping_Method $method
173
-	 */
174
-	private function add_shipping_details_with_shipping_method( &$jsonld, $product, $method = null ) {
169
+    /**
170
+     * @param array $jsonld
171
+     * @param Product $product
172
+     * @param Shipping_Method $method
173
+     */
174
+    private function add_shipping_details_with_shipping_method( &$jsonld, $product, $method = null ) {
175 175
 
176
-		$offer_shipping_details = array( '@type' => 'OfferShippingDetails', );
177
-		$shipping_delivery_time = array( '@type' => 'ShippingDeliveryTime', );
176
+        $offer_shipping_details = array( '@type' => 'OfferShippingDetails', );
177
+        $shipping_delivery_time = array( '@type' => 'ShippingDeliveryTime', );
178 178
 
179
-		$this->add_shipping_destination( $offer_shipping_details );
179
+        $this->add_shipping_destination( $offer_shipping_details );
180 180
 
181
-		/*
181
+        /*
182 182
 		 * Use Case UC003
183 183
 		 * 1.4.3
184 184
 		 */
185
-		if ( isset( $method ) ) {
186
-			$method->add_shipping_rate( $offer_shipping_details );
187
-			$method->add_transit_time( $shipping_delivery_time );
188
-		}
185
+        if ( isset( $method ) ) {
186
+            $method->add_shipping_rate( $offer_shipping_details );
187
+            $method->add_transit_time( $shipping_delivery_time );
188
+        }
189 189
 
190
-		/*
190
+        /*
191 191
 		 * Use Case UC004
192 192
 		 */
193
-		$product->add_handling_time( $shipping_delivery_time );
193
+        $product->add_handling_time( $shipping_delivery_time );
194 194
 
195
-		$this->add_cutoff_time( $shipping_delivery_time );
196
-		$this->add_business_days( $shipping_delivery_time );
195
+        $this->add_cutoff_time( $shipping_delivery_time );
196
+        $this->add_business_days( $shipping_delivery_time );
197 197
 
198
-		if ( 1 < count( $shipping_delivery_time ) ) {
199
-			$offer_shipping_details['shippingDeliveryTime'] = $shipping_delivery_time;
200
-		}
198
+        if ( 1 < count( $shipping_delivery_time ) ) {
199
+            $offer_shipping_details['shippingDeliveryTime'] = $shipping_delivery_time;
200
+        }
201 201
 
202
-		$jsonld['shippingDetails'][] = $offer_shipping_details;
202
+        $jsonld['shippingDetails'][] = $offer_shipping_details;
203 203
 
204
-	}
204
+    }
205 205
 
206
-	private function make_sure_shipping_details_exists_and_it_is_an_array( &$jsonld ) {
206
+    private function make_sure_shipping_details_exists_and_it_is_an_array( &$jsonld ) {
207 207
 
208
-		if ( ! isset( $jsonld['shippingDetails'] ) ) {
209
-			$jsonld['shippingDetails'] = array();
210
-		}
208
+        if ( ! isset( $jsonld['shippingDetails'] ) ) {
209
+            $jsonld['shippingDetails'] = array();
210
+        }
211 211
 
212
-		if ( ! is_array( $jsonld['shippingDetails'] ) ||
213
-		     ( ! empty( $jsonld['shippingDetails'] ) && ! is_numeric( key( $jsonld['shippingDetails'] ) ) ) ) {
214
-			$jsonld['shippingDetails'] = array( $jsonld['shippingDetails'] );
215
-		}
212
+        if ( ! is_array( $jsonld['shippingDetails'] ) ||
213
+             ( ! empty( $jsonld['shippingDetails'] ) && ! is_numeric( key( $jsonld['shippingDetails'] ) ) ) ) {
214
+            $jsonld['shippingDetails'] = array( $jsonld['shippingDetails'] );
215
+        }
216 216
 
217
-	}
217
+    }
218 218
 
219
-	private function add_shipping_destination( &$shipping_details ) {
219
+    private function add_shipping_destination( &$shipping_details ) {
220 220
 
221
-		if ( ! isset( $this->country_code ) ) {
222
-			return;
223
-		}
221
+        if ( ! isset( $this->country_code ) ) {
222
+            return;
223
+        }
224 224
 
225
-		$shipping_destination = array(
226
-			'@type'          => 'DefinedRegion',
227
-			'addressCountry' => $this->country_code,
228
-		);
225
+        $shipping_destination = array(
226
+            '@type'          => 'DefinedRegion',
227
+            'addressCountry' => $this->country_code,
228
+        );
229 229
 
230
-		$this->add_address_region( $shipping_destination );
231
-		$this->add_postal_code( $shipping_destination );
232
-		$this->add_postal_code_prefix( $shipping_destination );
233
-		$this->add_postal_code_range( $shipping_destination );
230
+        $this->add_address_region( $shipping_destination );
231
+        $this->add_postal_code( $shipping_destination );
232
+        $this->add_postal_code_prefix( $shipping_destination );
233
+        $this->add_postal_code_range( $shipping_destination );
234 234
 
235
-		$shipping_details['shippingDestination'] = $shipping_destination;
235
+        $shipping_details['shippingDestination'] = $shipping_destination;
236 236
 
237 237
 
238
-	}
238
+    }
239 239
 
240
-	private function add_address_region( &$shipping_destination ) {
240
+    private function add_address_region( &$shipping_destination ) {
241 241
 
242
-		if ( empty( $this->regions ) ) {
243
-			return;
244
-		}
242
+        if ( empty( $this->regions ) ) {
243
+            return;
244
+        }
245 245
 
246
-		$shipping_destination['addressRegion'] = $this->regions;
246
+        $shipping_destination['addressRegion'] = $this->regions;
247 247
 
248
-	}
248
+    }
249 249
 
250
-	private function add_postal_code( &$shipping_destination ) {
250
+    private function add_postal_code( &$shipping_destination ) {
251 251
 
252
-		if ( empty( $this->postal_codes ) ) {
253
-			return;
254
-		}
252
+        if ( empty( $this->postal_codes ) ) {
253
+            return;
254
+        }
255 255
 
256
-		$shipping_destination['postalCode'] = $this->postal_codes;
256
+        $shipping_destination['postalCode'] = $this->postal_codes;
257 257
 
258
-	}
258
+    }
259 259
 
260
-	private function add_postal_code_prefix( &$shipping_destination ) {
260
+    private function add_postal_code_prefix( &$shipping_destination ) {
261 261
 
262
-		if ( empty( $this->postal_code_prefixes ) ) {
263
-			return;
264
-		}
262
+        if ( empty( $this->postal_code_prefixes ) ) {
263
+            return;
264
+        }
265 265
 
266
-		foreach ( $this->postal_code_prefixes as $postal_code_prefix ) {
267
-			$shipping_destination['postalCodePrefix'][] = substr( $postal_code_prefix, 0, - 1 );
268
-		}
266
+        foreach ( $this->postal_code_prefixes as $postal_code_prefix ) {
267
+            $shipping_destination['postalCodePrefix'][] = substr( $postal_code_prefix, 0, - 1 );
268
+        }
269 269
 
270
-	}
270
+    }
271 271
 
272
-	private function add_postal_code_range( &$shipping_destination ) {
272
+    private function add_postal_code_range( &$shipping_destination ) {
273 273
 
274
-		if ( empty( $this->postal_code_ranges ) ) {
275
-			return;
276
-		}
274
+        if ( empty( $this->postal_code_ranges ) ) {
275
+            return;
276
+        }
277 277
 
278
-		$shipping_destination['postalCodeRanges'] = array();
279
-		foreach ( $this->postal_code_ranges as $post_code_range ) {
280
-			$range = explode( '...', $post_code_range );
278
+        $shipping_destination['postalCodeRanges'] = array();
279
+        foreach ( $this->postal_code_ranges as $post_code_range ) {
280
+            $range = explode( '...', $post_code_range );
281 281
 
282
-			$shipping_destination['postalCodeRanges'][] = array(
283
-				'postalCodeBegin' => $range[0],
284
-				'postalCodeEnd'   => $range[1],
285
-			);
286
-		}
282
+            $shipping_destination['postalCodeRanges'][] = array(
283
+                'postalCodeBegin' => $range[0],
284
+                'postalCodeEnd'   => $range[1],
285
+            );
286
+        }
287 287
 
288
-	}
288
+    }
289 289
 
290
-	public static function from_wc_shipping_zone( $wc_shipping_zone, $country_code = null ) {
290
+    public static function from_wc_shipping_zone( $wc_shipping_zone, $country_code = null ) {
291 291
 
292
-		return new self( $wc_shipping_zone, $country_code );
293
-	}
292
+        return new self( $wc_shipping_zone, $country_code );
293
+    }
294 294
 
295
-	private function add_cutoff_time( &$shipping_delivery_time ) {
295
+    private function add_cutoff_time( &$shipping_delivery_time ) {
296 296
 
297
-		$wpsso_options = get_option( 'wpsso_options' );
297
+        $wpsso_options = get_option( 'wpsso_options' );
298 298
 
299
-		if ( empty( $wpsso_options['wcsdt_shipdept_cutoff'] )
300
-		     || empty( $wpsso_options['wcsdt_shipdept_timezone'] ) ) {
301
-			return;
302
-		}
299
+        if ( empty( $wpsso_options['wcsdt_shipdept_cutoff'] )
300
+             || empty( $wpsso_options['wcsdt_shipdept_timezone'] ) ) {
301
+            return;
302
+        }
303 303
 
304
-		$cutoff_time = $wpsso_options['wcsdt_shipdept_cutoff'];
305
-		$timezone    = $wpsso_options['wcsdt_shipdept_timezone'];
304
+        $cutoff_time = $wpsso_options['wcsdt_shipdept_cutoff'];
305
+        $timezone    = $wpsso_options['wcsdt_shipdept_timezone'];
306 306
 
307
-		$time   = new DateTime( 'now', new DateTimeZone( $timezone ) );
308
-		$offset = $time->format( 'P' );
307
+        $time   = new DateTime( 'now', new DateTimeZone( $timezone ) );
308
+        $offset = $time->format( 'P' );
309 309
 
310
-		$shipping_delivery_time['cutOffTime'] = "{$cutoff_time}{$offset}";
310
+        $shipping_delivery_time['cutOffTime'] = "{$cutoff_time}{$offset}";
311 311
 
312
-	}
312
+    }
313 313
 
314
-	private function add_business_days( &$shipping_delivery_time ) {
314
+    private function add_business_days( &$shipping_delivery_time ) {
315 315
 
316
-		$wpsso_options = get_option( 'wpsso_options' );
316
+        $wpsso_options = get_option( 'wpsso_options' );
317 317
 
318
-		$day_of_week = array();
319
-		$prefix      = 'wcsdt_shipdept_day_';
320
-		foreach ( array( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ) as $day ) {
321
-			$key = $prefix . strtolower( $day );
318
+        $day_of_week = array();
319
+        $prefix      = 'wcsdt_shipdept_day_';
320
+        foreach ( array( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ) as $day ) {
321
+            $key = $prefix . strtolower( $day );
322 322
 
323
-			if (
324
-				( empty( $wpsso_options["{$key}_open"] ) && empty( $wpsso_options["{$key}_close"] ) )
325
-				|| ( 'none' === $wpsso_options["{$key}_open"] && 'none' === $wpsso_options["{$key}_close"] )
326
-			) {
327
-				continue;
328
-			}
323
+            if (
324
+                ( empty( $wpsso_options["{$key}_open"] ) && empty( $wpsso_options["{$key}_close"] ) )
325
+                || ( 'none' === $wpsso_options["{$key}_open"] && 'none' === $wpsso_options["{$key}_close"] )
326
+            ) {
327
+                continue;
328
+            }
329 329
 
330
-			$day_of_week[] = "https://schema.org/$day";
331
-		}
330
+            $day_of_week[] = "https://schema.org/$day";
331
+        }
332 332
 
333
-		if ( ! empty( $day_of_week ) ) {
334
-			$shipping_delivery_time['businessDays'] = array(
335
-				'@type'     => 'OpeningHoursSpecification',
336
-				'dayOfWeek' => $day_of_week,
337
-			);
338
-		}
333
+        if ( ! empty( $day_of_week ) ) {
334
+            $shipping_delivery_time['businessDays'] = array(
335
+                '@type'     => 'OpeningHoursSpecification',
336
+                'dayOfWeek' => $day_of_week,
337
+            );
338
+        }
339 339
 
340
-	}
340
+    }
341 341
 
342 342
 }
343 343
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param WC_Shipping_Zone $wc_shipping_zone
52 52
 	 * @param string $country_code
53 53
 	 */
54
-	public function __construct( $wc_shipping_zone, $country_code ) {
54
+	public function __construct($wc_shipping_zone, $country_code) {
55 55
 
56 56
 		$this->wc_shipping_zone = $wc_shipping_zone;
57 57
 		$this->country_code     = $country_code;
@@ -68,23 +68,23 @@  discard block
 block discarded – undo
68 68
 		$this->postal_code_ranges   = array();
69 69
 
70 70
 		// Bail out if country code isn't set.
71
-		if ( ! isset( $this->country_code ) ) {
71
+		if ( ! isset($this->country_code)) {
72 72
 			return;
73 73
 		}
74 74
 
75
-		foreach ( $this->wc_shipping_zone->get_zone_locations() as $zone_location ) {
76
-			switch ( $zone_location->type ) {
75
+		foreach ($this->wc_shipping_zone->get_zone_locations() as $zone_location) {
76
+			switch ($zone_location->type) {
77 77
 				case 'state':
78
-					if ( 0 === strpos( $zone_location->code, "$this->country_code:" ) ) {
79
-						$this->regions[] = substr( $zone_location->code, 3 );
78
+					if (0 === strpos($zone_location->code, "$this->country_code:")) {
79
+						$this->regions[] = substr($zone_location->code, 3);
80 80
 					}
81 81
 
82 82
 					break;
83 83
 
84 84
 				case 'postcode':
85
-					if ( '*' === substr( $zone_location->code, - 1 ) ) {
85
+					if ('*' === substr($zone_location->code, - 1)) {
86 86
 						$this->postal_code_prefixes[] = $zone_location->code;
87
-					} else if ( - 1 < strpos( $zone_location->code, '...' ) ) {
87
+					} else if ( -1 < strpos($zone_location->code, '...') ) {
88 88
 						$this->postal_code_ranges[] = $zone_location->code;
89 89
 					} else {
90 90
 						$this->postal_codes[] = $zone_location->code;
@@ -100,17 +100,17 @@  discard block
 block discarded – undo
100 100
 
101 101
 	private function load_methods() {
102 102
 
103
-		$this->methods = array_map( 'Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method',
104
-			$this->wc_shipping_zone->get_shipping_methods( true ) );
103
+		$this->methods = array_map('Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method',
104
+			$this->wc_shipping_zone->get_shipping_methods(true));
105 105
 
106 106
 	}
107 107
 
108
-	public function add_available_delivery_method( &$jsonld ) {
108
+	public function add_available_delivery_method(&$jsonld) {
109 109
 
110 110
 		$this->load_methods();
111 111
 
112
-		foreach ( $this->methods as $method ) {
113
-			$method->add_available_delivery_method( $jsonld );
112
+		foreach ($this->methods as $method) {
113
+			$method->add_available_delivery_method($jsonld);
114 114
 		}
115 115
 
116 116
 	}
@@ -119,22 +119,22 @@  discard block
 block discarded – undo
119 119
 	 * @param array $jsonld
120 120
 	 * @param Product $product
121 121
 	 */
122
-	public function add_offer_shipping_details( &$jsonld, $product ) {
122
+	public function add_offer_shipping_details(&$jsonld, $product) {
123 123
 
124 124
 		$this->load_methods();
125 125
 
126 126
 		// Ignore the default zone if no methods are configured.
127
-		if ( 0 === $this->wc_shipping_zone->get_id() && 0 === count( $this->methods ) ) {
127
+		if (0 === $this->wc_shipping_zone->get_id() && 0 === count($this->methods)) {
128 128
 			return;
129 129
 		}
130 130
 
131
-		$this->make_sure_shipping_details_exists_and_it_is_an_array( $jsonld );
131
+		$this->make_sure_shipping_details_exists_and_it_is_an_array($jsonld);
132 132
 
133
-		if ( empty( $this->methods ) ) {
134
-			$this->add_shipping_details_with_shipping_method( $jsonld, $product );
133
+		if (empty($this->methods)) {
134
+			$this->add_shipping_details_with_shipping_method($jsonld, $product);
135 135
 		} else {
136
-			foreach ( $this->methods as $method ) {
137
-				$this->add_shipping_details_with_shipping_method( $jsonld, $product, $method );
136
+			foreach ($this->methods as $method) {
137
+				$this->add_shipping_details_with_shipping_method($jsonld, $product, $method);
138 138
 			}
139 139
 		}
140 140
 
@@ -171,31 +171,31 @@  discard block
 block discarded – undo
171 171
 	 * @param Product $product
172 172
 	 * @param Shipping_Method $method
173 173
 	 */
174
-	private function add_shipping_details_with_shipping_method( &$jsonld, $product, $method = null ) {
174
+	private function add_shipping_details_with_shipping_method(&$jsonld, $product, $method = null) {
175 175
 
176
-		$offer_shipping_details = array( '@type' => 'OfferShippingDetails', );
177
-		$shipping_delivery_time = array( '@type' => 'ShippingDeliveryTime', );
176
+		$offer_shipping_details = array('@type' => 'OfferShippingDetails',);
177
+		$shipping_delivery_time = array('@type' => 'ShippingDeliveryTime',);
178 178
 
179
-		$this->add_shipping_destination( $offer_shipping_details );
179
+		$this->add_shipping_destination($offer_shipping_details);
180 180
 
181 181
 		/*
182 182
 		 * Use Case UC003
183 183
 		 * 1.4.3
184 184
 		 */
185
-		if ( isset( $method ) ) {
186
-			$method->add_shipping_rate( $offer_shipping_details );
187
-			$method->add_transit_time( $shipping_delivery_time );
185
+		if (isset($method)) {
186
+			$method->add_shipping_rate($offer_shipping_details);
187
+			$method->add_transit_time($shipping_delivery_time);
188 188
 		}
189 189
 
190 190
 		/*
191 191
 		 * Use Case UC004
192 192
 		 */
193
-		$product->add_handling_time( $shipping_delivery_time );
193
+		$product->add_handling_time($shipping_delivery_time);
194 194
 
195
-		$this->add_cutoff_time( $shipping_delivery_time );
196
-		$this->add_business_days( $shipping_delivery_time );
195
+		$this->add_cutoff_time($shipping_delivery_time);
196
+		$this->add_business_days($shipping_delivery_time);
197 197
 
198
-		if ( 1 < count( $shipping_delivery_time ) ) {
198
+		if (1 < count($shipping_delivery_time)) {
199 199
 			$offer_shipping_details['shippingDeliveryTime'] = $shipping_delivery_time;
200 200
 		}
201 201
 
@@ -203,22 +203,22 @@  discard block
 block discarded – undo
203 203
 
204 204
 	}
205 205
 
206
-	private function make_sure_shipping_details_exists_and_it_is_an_array( &$jsonld ) {
206
+	private function make_sure_shipping_details_exists_and_it_is_an_array(&$jsonld) {
207 207
 
208
-		if ( ! isset( $jsonld['shippingDetails'] ) ) {
208
+		if ( ! isset($jsonld['shippingDetails'])) {
209 209
 			$jsonld['shippingDetails'] = array();
210 210
 		}
211 211
 
212
-		if ( ! is_array( $jsonld['shippingDetails'] ) ||
213
-		     ( ! empty( $jsonld['shippingDetails'] ) && ! is_numeric( key( $jsonld['shippingDetails'] ) ) ) ) {
214
-			$jsonld['shippingDetails'] = array( $jsonld['shippingDetails'] );
212
+		if ( ! is_array($jsonld['shippingDetails']) ||
213
+		     ( ! empty($jsonld['shippingDetails']) && ! is_numeric(key($jsonld['shippingDetails'])))) {
214
+			$jsonld['shippingDetails'] = array($jsonld['shippingDetails']);
215 215
 		}
216 216
 
217 217
 	}
218 218
 
219
-	private function add_shipping_destination( &$shipping_details ) {
219
+	private function add_shipping_destination(&$shipping_details) {
220 220
 
221
-		if ( ! isset( $this->country_code ) ) {
221
+		if ( ! isset($this->country_code)) {
222 222
 			return;
223 223
 		}
224 224
 
@@ -227,19 +227,19 @@  discard block
 block discarded – undo
227 227
 			'addressCountry' => $this->country_code,
228 228
 		);
229 229
 
230
-		$this->add_address_region( $shipping_destination );
231
-		$this->add_postal_code( $shipping_destination );
232
-		$this->add_postal_code_prefix( $shipping_destination );
233
-		$this->add_postal_code_range( $shipping_destination );
230
+		$this->add_address_region($shipping_destination);
231
+		$this->add_postal_code($shipping_destination);
232
+		$this->add_postal_code_prefix($shipping_destination);
233
+		$this->add_postal_code_range($shipping_destination);
234 234
 
235 235
 		$shipping_details['shippingDestination'] = $shipping_destination;
236 236
 
237 237
 
238 238
 	}
239 239
 
240
-	private function add_address_region( &$shipping_destination ) {
240
+	private function add_address_region(&$shipping_destination) {
241 241
 
242
-		if ( empty( $this->regions ) ) {
242
+		if (empty($this->regions)) {
243 243
 			return;
244 244
 		}
245 245
 
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 
248 248
 	}
249 249
 
250
-	private function add_postal_code( &$shipping_destination ) {
250
+	private function add_postal_code(&$shipping_destination) {
251 251
 
252
-		if ( empty( $this->postal_codes ) ) {
252
+		if (empty($this->postal_codes)) {
253 253
 			return;
254 254
 		}
255 255
 
@@ -257,27 +257,27 @@  discard block
 block discarded – undo
257 257
 
258 258
 	}
259 259
 
260
-	private function add_postal_code_prefix( &$shipping_destination ) {
260
+	private function add_postal_code_prefix(&$shipping_destination) {
261 261
 
262
-		if ( empty( $this->postal_code_prefixes ) ) {
262
+		if (empty($this->postal_code_prefixes)) {
263 263
 			return;
264 264
 		}
265 265
 
266
-		foreach ( $this->postal_code_prefixes as $postal_code_prefix ) {
267
-			$shipping_destination['postalCodePrefix'][] = substr( $postal_code_prefix, 0, - 1 );
266
+		foreach ($this->postal_code_prefixes as $postal_code_prefix) {
267
+			$shipping_destination['postalCodePrefix'][] = substr($postal_code_prefix, 0, - 1);
268 268
 		}
269 269
 
270 270
 	}
271 271
 
272
-	private function add_postal_code_range( &$shipping_destination ) {
272
+	private function add_postal_code_range(&$shipping_destination) {
273 273
 
274
-		if ( empty( $this->postal_code_ranges ) ) {
274
+		if (empty($this->postal_code_ranges)) {
275 275
 			return;
276 276
 		}
277 277
 
278 278
 		$shipping_destination['postalCodeRanges'] = array();
279
-		foreach ( $this->postal_code_ranges as $post_code_range ) {
280
-			$range = explode( '...', $post_code_range );
279
+		foreach ($this->postal_code_ranges as $post_code_range) {
280
+			$range = explode('...', $post_code_range);
281 281
 
282 282
 			$shipping_destination['postalCodeRanges'][] = array(
283 283
 				'postalCodeBegin' => $range[0],
@@ -287,42 +287,42 @@  discard block
 block discarded – undo
287 287
 
288 288
 	}
289 289
 
290
-	public static function from_wc_shipping_zone( $wc_shipping_zone, $country_code = null ) {
290
+	public static function from_wc_shipping_zone($wc_shipping_zone, $country_code = null) {
291 291
 
292
-		return new self( $wc_shipping_zone, $country_code );
292
+		return new self($wc_shipping_zone, $country_code);
293 293
 	}
294 294
 
295
-	private function add_cutoff_time( &$shipping_delivery_time ) {
295
+	private function add_cutoff_time(&$shipping_delivery_time) {
296 296
 
297
-		$wpsso_options = get_option( 'wpsso_options' );
297
+		$wpsso_options = get_option('wpsso_options');
298 298
 
299
-		if ( empty( $wpsso_options['wcsdt_shipdept_cutoff'] )
300
-		     || empty( $wpsso_options['wcsdt_shipdept_timezone'] ) ) {
299
+		if (empty($wpsso_options['wcsdt_shipdept_cutoff'])
300
+		     || empty($wpsso_options['wcsdt_shipdept_timezone'])) {
301 301
 			return;
302 302
 		}
303 303
 
304 304
 		$cutoff_time = $wpsso_options['wcsdt_shipdept_cutoff'];
305 305
 		$timezone    = $wpsso_options['wcsdt_shipdept_timezone'];
306 306
 
307
-		$time   = new DateTime( 'now', new DateTimeZone( $timezone ) );
308
-		$offset = $time->format( 'P' );
307
+		$time   = new DateTime('now', new DateTimeZone($timezone));
308
+		$offset = $time->format('P');
309 309
 
310 310
 		$shipping_delivery_time['cutOffTime'] = "{$cutoff_time}{$offset}";
311 311
 
312 312
 	}
313 313
 
314
-	private function add_business_days( &$shipping_delivery_time ) {
314
+	private function add_business_days(&$shipping_delivery_time) {
315 315
 
316
-		$wpsso_options = get_option( 'wpsso_options' );
316
+		$wpsso_options = get_option('wpsso_options');
317 317
 
318 318
 		$day_of_week = array();
319 319
 		$prefix      = 'wcsdt_shipdept_day_';
320
-		foreach ( array( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ) as $day ) {
321
-			$key = $prefix . strtolower( $day );
320
+		foreach (array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') as $day) {
321
+			$key = $prefix.strtolower($day);
322 322
 
323 323
 			if (
324
-				( empty( $wpsso_options["{$key}_open"] ) && empty( $wpsso_options["{$key}_close"] ) )
325
-				|| ( 'none' === $wpsso_options["{$key}_open"] && 'none' === $wpsso_options["{$key}_close"] )
324
+				(empty($wpsso_options["{$key}_open"]) && empty($wpsso_options["{$key}_close"]))
325
+				|| ('none' === $wpsso_options["{$key}_open"] && 'none' === $wpsso_options["{$key}_close"])
326 326
 			) {
327 327
 				continue;
328 328
 			}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 			$day_of_week[] = "https://schema.org/$day";
331 331
 		}
332 332
 
333
-		if ( ! empty( $day_of_week ) ) {
333
+		if ( ! empty($day_of_week)) {
334 334
 			$shipping_delivery_time['businessDays'] = array(
335 335
 				'@type'     => 'OpeningHoursSpecification',
336 336
 				'dayOfWeek' => $day_of_week,
Please login to merge, or discard this patch.