@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | class wps_shipping {
|
| 3 | 5 | function __construct() {
|
| 4 | 6 | |
@@ -21,8 +23,7 @@ discard block |
||
| 21 | 23 | $temp_data[$value] = $atts[2][$key]; |
| 22 | 24 | if($value=='destination') {
|
| 23 | 25 | $country_code = $atts[2][$key]; |
| 24 | - } |
|
| 25 | - elseif($value=='fees') {
|
|
| 26 | + } elseif($value=='fees') {
|
|
| 26 | 27 | $fees_data = array(); |
| 27 | 28 | $fees = explode(',', $atts[2][$key]);
|
| 28 | 29 | foreach($fees as $fee){
|
@@ -39,8 +40,7 @@ discard block |
||
| 39 | 40 | $number_1 = count($fees_data_1); |
| 40 | 41 | if ($number == $number_1) {
|
| 41 | 42 | $temp_data[$value] = $fees_data; |
| 42 | - } |
|
| 43 | - else {
|
|
| 43 | + } else {
|
|
| 44 | 44 | $temp_data[$value] = $fees_data_1; |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -68,9 +68,13 @@ discard block |
||
| 68 | 68 | foreach($d as $att => $value) {
|
| 69 | 69 | $val = ''; |
| 70 | 70 | if($att=='fees') {
|
| 71 | - foreach($value as $_k=>$_value) $val .= $_k.':'.$_value.', '; |
|
| 71 | + foreach($value as $_k=>$_value) { |
|
| 72 | + $val .= $_k.':'.$_value.', '; |
|
| 73 | + } |
|
| 72 | 74 | $val = substr($val,0,-2); |
| 73 | - } else $val = $value; |
|
| 75 | + } else { |
|
| 76 | + $val = $value; |
|
| 77 | + } |
|
| 74 | 78 | $string .= $att.': "'.$val.'",'."\n"; |
| 75 | 79 | } |
| 76 | 80 | $string = substr($string,0,-2)."\n"; |
@@ -78,8 +82,9 @@ discard block |
||
| 78 | 82 | } |
| 79 | 83 | $string = substr($string,0,-2); |
| 80 | 84 | return $string; |
| 81 | - } |
|
| 82 | - else return false; |
|
| 85 | + } else { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 83 | 88 | } |
| 84 | 89 | |
| 85 | 90 | /** |
@@ -116,8 +121,7 @@ discard block |
||
| 116 | 121 | $chosen_shipping_mode = 'default_choice'; |
| 117 | 122 | } |
| 118 | 123 | } |
| 119 | - } |
|
| 120 | - else {
|
|
| 124 | + } else {
|
|
| 121 | 125 | if( !empty( $_SESSION['shipping_method'] ) ) {
|
| 122 | 126 | $chosen_shipping_mode = wpshop_tools::varSanitizer( $_SESSION['shipping_method'] ); |
| 123 | 127 | } else {
|
@@ -163,8 +167,7 @@ discard block |
||
| 163 | 167 | /** Free Shipping From **/ |
| 164 | 168 | elseif( !empty($selected_shipping_mode_config) && !empty($selected_shipping_mode_config['free_from']) && $selected_shipping_mode_config['free_from'] >= 0 && $selected_shipping_mode_config['free_from'] <= number_format( $total_cart, 2, '.', '') ) {
|
| 165 | 169 | $shipping_cost = 0; |
| 166 | - } |
|
| 167 | - else {
|
|
| 170 | + } else {
|
|
| 168 | 171 | /** Check Custom Shipping Cost **/ |
| 169 | 172 | |
| 170 | 173 | if ( !empty($selected_shipping_mode_config['custom_shipping_rules']) && !empty($selected_shipping_mode_config['custom_shipping_rules']['active']) ) {
|
@@ -178,8 +181,7 @@ discard block |
||
| 178 | 181 | $postcode = $address_infos['postcode']; |
| 179 | 182 | if ( array_key_exists($country.'-'.$postcode, $selected_shipping_mode_config['custom_shipping_rules']['fees']) ) {
|
| 180 | 183 | $country = $country.'-'.$postcode; |
| 181 | - } |
|
| 182 | - elseif( array_key_exists($country.'-OTHERS', $selected_shipping_mode_config['custom_shipping_rules']['fees']) ) {
|
|
| 184 | + } elseif( array_key_exists($country.'-OTHERS', $selected_shipping_mode_config['custom_shipping_rules']['fees']) ) {
|
|
| 183 | 185 | $country = $country.'-OTHERS'; |
| 184 | 186 | } |
| 185 | 187 | } |
@@ -190,8 +192,7 @@ discard block |
||
| 190 | 192 | if ( !empty($selected_shipping_mode_config['min_max']) && !empty($selected_shipping_mode_config['min_max']['activate']) ) {
|
| 191 | 193 | if ( !empty($selected_shipping_mode_config['min_max']['min']) && $shipping_cost < $selected_shipping_mode_config['min_max']['min'] ) {
|
| 192 | 194 | $shipping_cost = $selected_shipping_mode_config['min_max']['min']; |
| 193 | - } |
|
| 194 | - elseif( !empty($selected_shipping_mode_config['min_max']['max']) &&$shipping_cost > $selected_shipping_mode_config['min_max']['max']) {
|
|
| 195 | + } elseif( !empty($selected_shipping_mode_config['min_max']['max']) &&$shipping_cost > $selected_shipping_mode_config['min_max']['max']) {
|
|
| 195 | 196 | $shipping_cost = $selected_shipping_mode_config['min_max']['max']; |
| 196 | 197 | } |
| 197 | 198 | |
@@ -269,11 +270,9 @@ discard block |
||
| 269 | 270 | if( !$found_active_cp_rule && !$found_active_departement_rule ){
|
| 270 | 271 | if ( array_key_exists($dest, $fees) ) {
|
| 271 | 272 | $key = $dest; |
| 272 | - } |
|
| 273 | - elseif( array_key_exists( 'OTHERS', $fees) ) {
|
|
| 273 | + } elseif( array_key_exists( 'OTHERS', $fees) ) {
|
|
| 274 | 274 | $key = 'OTHERS'; |
| 275 | - } |
|
| 276 | - else {
|
|
| 275 | + } else {
|
|
| 277 | 276 | return false; |
| 278 | 277 | } |
| 279 | 278 | } |
@@ -290,8 +289,7 @@ discard block |
||
| 290 | 289 | $price = $shipping_price; |
| 291 | 290 | } |
| 292 | 291 | } |
| 293 | - } |
|
| 294 | - else {
|
|
| 292 | + } else {
|
|
| 295 | 293 | return false; |
| 296 | 294 | } |
| 297 | 295 | return $price; |
@@ -333,15 +331,13 @@ discard block |
||
| 333 | 331 | $product_data = get_post_meta( $id_item, '_wpshop_product_metadata', true ); |
| 334 | 332 | if ( !empty($product_data) && !empty($product_data['product_weight']) ) {
|
| 335 | 333 | $cart_weight += ( $product_data['product_weight'] * $cart_item['item_qty'] ); |
| 336 | - } |
|
| 337 | - else {
|
|
| 334 | + } else {
|
|
| 338 | 335 | $parent_def = wpshop_products::get_parent_variation( $id_item ); |
| 339 | 336 | if ( !empty($parent_def) && !empty( $parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['product_weight']) ) {
|
| 340 | 337 | $cart_weight += ( $parent_def['parent_post_meta']['product_weight'] * $cart_item['item_qty'] ); |
| 341 | 338 | } |
| 342 | 339 | } |
| 343 | - } |
|
| 344 | - else {
|
|
| 340 | + } else {
|
|
| 345 | 341 | $product_data = get_post_meta( $cart_item['item_id'], '_wpshop_product_metadata', true ); |
| 346 | 342 | if ( !empty($product_data) && !empty($product_data['product_weight']) && !empty($cart_item['item_qty']) ) {
|
| 347 | 343 | $cart_weight += ( $product_data['product_weight'] * $cart_item['item_qty'] ); |