@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | if( !empty($posted_opinions) ) : ?> |
| 3 | 5 | <span class="wps-h5"><?php _e( 'My opinions', 'wpshop'); ?></span> |
| 4 | 6 | <div class="wps-table"> |
@@ -18,6 +20,9 @@ discard block |
||
| 18 | 20 | endif; |
| 19 | 21 | ?> |
| 20 | 22 | </div> |
| 21 | -<?php else : ?> |
|
| 22 | -<div class="wps-alert-info"><?php _e( 'You never posted an opinion on a product', 'wpshop'); ?></div> |
|
| 23 | +<?php else { |
|
| 24 | + : ?> |
|
| 25 | +<div class="wps-alert-info"><?php _e( 'You never posted an opinion on a product', 'wpshop'); |
|
| 26 | +} |
|
| 27 | +?></div> |
|
| 23 | 28 | <?php endif; ?> |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | class wps_cart { |
| 3 | 5 | |
| 4 | 6 | function __construct() { |
@@ -151,12 +153,10 @@ discard block |
||
| 151 | 153 | require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/cart") ); |
| 152 | 154 | $output = ob_get_contents(); |
| 153 | 155 | ob_end_clean(); |
| 154 | - } |
|
| 155 | - else { |
|
| 156 | + } else { |
|
| 156 | 157 | return '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';; |
| 157 | 158 | } |
| 158 | - } |
|
| 159 | - else { |
|
| 159 | + } else { |
|
| 160 | 160 | return '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';; |
| 161 | 161 | } |
| 162 | 162 | return $output; |
@@ -174,15 +174,13 @@ discard block |
||
| 174 | 174 | /** Count items **/ |
| 175 | 175 | $total_cart_item = self::total_cart_items( $cart_items ); |
| 176 | 176 | $mini_cart_body = self::mini_cart_content( $type ); |
| 177 | - } |
|
| 178 | - else { |
|
| 177 | + } else { |
|
| 179 | 178 | $mini_cart_body = self::mini_cart_content(); |
| 180 | 179 | } |
| 181 | 180 | ob_start(); |
| 182 | 181 | if( !empty($type) && $type == 'fixed' ) { |
| 183 | 182 | require(wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart") ); |
| 184 | - } |
|
| 185 | - else { |
|
| 183 | + } else { |
|
| 186 | 184 | require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart") ); |
| 187 | 185 | } |
| 188 | 186 | |
@@ -210,18 +208,15 @@ discard block |
||
| 210 | 208 | ob_start(); |
| 211 | 209 | if( !empty($type) && $type == 'fixed' ) { |
| 212 | 210 | require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart", "content") ); |
| 213 | - } |
|
| 214 | - else { |
|
| 211 | + } else { |
|
| 215 | 212 | require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart", "content") ); |
| 216 | 213 | } |
| 217 | 214 | $output = ob_get_contents(); |
| 218 | 215 | ob_end_clean(); |
| 219 | - } |
|
| 220 | - else { |
|
| 216 | + } else { |
|
| 221 | 217 | $output = '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>'; |
| 222 | 218 | } |
| 223 | - } |
|
| 224 | - else { |
|
| 219 | + } else { |
|
| 225 | 220 | $output = '<div class="wps-alert-info">' . __( 'Your cart is empty', 'wpshop' ).'</div>'; |
| 226 | 221 | } |
| 227 | 222 | return $output; |
@@ -256,12 +251,10 @@ discard block |
||
| 256 | 251 | require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart", "content") ); |
| 257 | 252 | $output = ob_get_contents(); |
| 258 | 253 | ob_end_clean(); |
| 259 | - } |
|
| 260 | - else { |
|
| 254 | + } else { |
|
| 261 | 255 | $resume_cart_body = '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>'; |
| 262 | 256 | } |
| 263 | - } |
|
| 264 | - else { |
|
| 257 | + } else { |
|
| 265 | 258 | $resume_cart_body ='<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>'; |
| 266 | 259 | } |
| 267 | 260 | return $output; |
@@ -298,8 +291,9 @@ discard block |
||
| 298 | 291 | * @return array() |
| 299 | 292 | */ |
| 300 | 293 | function get_persistent_cart() { |
| 301 | - if(get_current_user_id()) |
|
| 302 | - $cart = get_user_meta(get_current_user_id(), '_wpshop_persistent_cart', true); |
|
| 294 | + if(get_current_user_id()) { |
|
| 295 | + $cart = get_user_meta(get_current_user_id(), '_wpshop_persistent_cart', true); |
|
| 296 | + } |
|
| 303 | 297 | return empty($cart) ? array() : $cart; |
| 304 | 298 | } |
| 305 | 299 | |
@@ -314,10 +308,11 @@ discard block |
||
| 314 | 308 | * Save the persistent cart when updated |
| 315 | 309 | */ |
| 316 | 310 | function persistent_cart_update() { |
| 317 | - if(get_current_user_id()) |
|
| 318 | - update_user_meta( get_current_user_id(), '_wpshop_persistent_cart', array( |
|
| 311 | + if(get_current_user_id()) { |
|
| 312 | + update_user_meta( get_current_user_id(), '_wpshop_persistent_cart', array( |
|
| 319 | 313 | 'cart' => $_SESSION['cart'], |
| 320 | 314 | )); |
| 315 | + } |
|
| 321 | 316 | } |
| 322 | 317 | |
| 323 | 318 | /** |
@@ -372,8 +367,7 @@ discard block |
||
| 372 | 367 | // Check Parent ID |
| 373 | 368 | if( get_post_type($cart['order_items'][ $product_id ]['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
| 374 | 369 | $parent_product_id = $cart['order_items'][ $product_id ]['item_id']; |
| 375 | - } |
|
| 376 | - else { |
|
| 370 | + } else { |
|
| 377 | 371 | $parent_data = wpshop_products::get_parent_variation( $cart['order_items'][ $product_id ]['item_id'] ); |
| 378 | 372 | $parent_post = $parent_data['parent_post']; |
| 379 | 373 | $parent_product_id = $parent_post->ID; |
@@ -388,8 +382,7 @@ discard block |
||
| 388 | 382 | } |
| 389 | 383 | } |
| 390 | 384 | } |
| 391 | - } |
|
| 392 | - else { |
|
| 385 | + } else { |
|
| 393 | 386 | $selected_variations = get_post_meta( $product_id, '_wpshop_variations_attribute_def', true ); |
| 394 | 387 | } |
| 395 | 388 | } |
@@ -399,8 +392,7 @@ discard block |
||
| 399 | 392 | $new_pid = $product_id; |
| 400 | 393 | $return = $this->add_to_cart( $product_to_add_to_cart, array( $new_pid => $quantity ), $wpshop_cart_type, array(), $from_admin, $cart, $order_id ); |
| 401 | 394 | return $return; |
| 402 | - } |
|
| 403 | - else { |
|
| 395 | + } else { |
|
| 404 | 396 | return __('This product does not exist in the cart.', 'wpshop'); |
| 405 | 397 | } |
| 406 | 398 | } |
@@ -416,8 +408,7 @@ discard block |
||
| 416 | 408 | if ( empty( $from_admin ) ){ |
| 417 | 409 | if(isset($_SESSION['cart']['cart_type']) && $type != $_SESSION['cart']['cart_type'] ) { |
| 418 | 410 | return __('You have another element type into your cart. Please finalize it by going to cart page.', 'wpshop'); |
| 419 | - } |
|
| 420 | - else { |
|
| 411 | + } else { |
|
| 421 | 412 | $_SESSION['cart']['cart_type'] = $type; |
| 422 | 413 | } |
| 423 | 414 | $order_meta = $_SESSION['cart']; |
@@ -428,22 +419,27 @@ discard block |
||
| 428 | 419 | |
| 429 | 420 | foreach ($product_list as $pid => $product_more_content) { |
| 430 | 421 | if ( count($product_list) == 1 ) { |
| 431 | - if ( !isset( $quantity[$pid] ) ) $quantity[$pid] = 1; |
|
| 422 | + if ( !isset( $quantity[$pid] ) ) { |
|
| 423 | + $quantity[$pid] = 1; |
|
| 424 | + } |
|
| 432 | 425 | $product = wpshop_products::get_product_data($product_more_content['id'], false, '"publish", "free_product"'); |
| 433 | 426 | /** Check if the selected product exist */ |
| 434 | - if ( $product === false ) return __('This product does not exist', 'wpshop'); |
|
| 427 | + if ( $product === false ) { |
|
| 428 | + return __('This product does not exist', 'wpshop'); |
|
| 429 | + } |
|
| 435 | 430 | |
| 436 | 431 | /** Get information about the product price */ |
| 437 | 432 | $product_price_check = wpshop_prices::get_product_price($product, 'check_only'); |
| 438 | - if ( $product_price_check !== true ) return $product_price_check; |
|
| 433 | + if ( $product_price_check !== true ) { |
|
| 434 | + return $product_price_check; |
|
| 435 | + } |
|
| 439 | 436 | |
| 440 | 437 | $the_quantity = 1; |
| 441 | 438 | |
| 442 | 439 | if ( !empty($product_more_content['defined_variation_priority']) && $product_more_content['defined_variation_priority'] == 'combined' && !empty($product_more_content['variations']) && !empty($product_more_content['variations'][0]) ) { |
| 443 | 440 | /** Get the asked quantity for each product and check if there is enough stock */ |
| 444 | 441 | $the_quantity = $quantity[$pid]; |
| 445 | - } |
|
| 446 | - else { |
|
| 442 | + } else { |
|
| 447 | 443 | /** Get the asked quantity for each product and check if there is enough stock */ |
| 448 | 444 | $the_quantity = $quantity[$pid]; |
| 449 | 445 | } |
@@ -486,8 +482,7 @@ discard block |
||
| 486 | 482 | if ( get_current_user_id() ) { |
| 487 | 483 | $this->persistent_cart_update(); |
| 488 | 484 | } |
| 489 | - } |
|
| 490 | - else { |
|
| 485 | + } else { |
|
| 491 | 486 | update_post_meta($order_id, '_order_postmeta', $order ); |
| 492 | 487 | |
| 493 | 488 | } |
@@ -631,8 +626,7 @@ discard block |
||
| 631 | 626 | if( empty( $d['product_qty'] ) ) { |
| 632 | 627 | unset( $cart_items[$product_key] ); |
| 633 | 628 | unset( $cart_infos['order_items'][$product_key] ); |
| 634 | - } |
|
| 635 | - else { |
|
| 629 | + } else { |
|
| 636 | 630 | $wps_orders = new wps_orders_ctr(); |
| 637 | 631 | $cart_items[$product_key] = $wps_orders->add_product_to_order($the_product); |
| 638 | 632 | } |
@@ -651,8 +645,7 @@ discard block |
||
| 651 | 645 | if ( !empty( $item[ 'item_amount_to_pay_now' ] ) ) { |
| 652 | 646 | $cart_has_special_product = true; |
| 653 | 647 | $cart_infos['order_amount_to_pay_now'] += ( $item[ 'item_amount_to_pay_now' ] * $item[ 'item_qty' ] ); |
| 654 | - } |
|
| 655 | - else { |
|
| 648 | + } else { |
|
| 656 | 649 | $cart_infos['order_amount_to_pay_now'] += $item['item_total_ttc']; |
| 657 | 650 | } |
| 658 | 651 | |
@@ -661,13 +654,11 @@ discard block |
||
| 661 | 654 | // VAT |
| 662 | 655 | if( !empty($order_tva[ $item['item_tva_rate'] ]) ) { |
| 663 | 656 | $order_tva[ $item['item_tva_rate'] ] += $item['item_tva_total_amount']; |
| 664 | - } |
|
| 665 | - else { |
|
| 657 | + } else { |
|
| 666 | 658 | $order_tva[ $item['item_tva_rate'] ] = $item['item_tva_total_amount']; |
| 667 | 659 | } |
| 668 | 660 | } |
| 669 | - } |
|
| 670 | - else { |
|
| 661 | + } else { |
|
| 671 | 662 | return array(); |
| 672 | 663 | } |
| 673 | 664 | |
@@ -764,8 +755,7 @@ discard block |
||
| 764 | 755 | } |
| 765 | 756 | if ( number_format( $cart_infos['order_discount_amount_total_cart'], 2, '.', '') > number_format( $cart_infos['order_grand_total'], 2, '.', '') ) { |
| 766 | 757 | $cart_infos['order_grand_total'] = 0; |
| 767 | - } |
|
| 768 | - else { |
|
| 758 | + } else { |
|
| 769 | 759 | $cart_infos['order_grand_total'] -= number_format( $cart_infos['order_discount_amount_total_cart'], 2, '.', ''); |
| 770 | 760 | } |
| 771 | 761 | $cart_infos['order_amount_to_pay_now'] = number_format( $cart_infos['order_grand_total'] - $total_received, 2, '.', ''); |
@@ -775,8 +765,7 @@ discard block |
||
| 775 | 765 | $wpshop_payment = new wpshop_payment(); |
| 776 | 766 | if( !empty($cart_infos['cart_type']) && $cart_infos['cart_type'] == 'quotation' ) { |
| 777 | 767 | $partial_payment = $wpshop_payment->partial_payment_calcul( $cart_infos['order_grand_total'], 'for_quotation' ); |
| 778 | - } |
|
| 779 | - else { |
|
| 768 | + } else { |
|
| 780 | 769 | $partial_payment = $wpshop_payment->partial_payment_calcul( $cart_infos['order_grand_total'] ); |
| 781 | 770 | } |
| 782 | 771 | if ( !empty($partial_payment['amount_to_pay']) && ( empty( $cart_infos['order_status'] ) || $cart_infos['order_status'] == 'awaiting_payment' ) && ( empty( $product_partial_payment_amount ) ) ) { |
@@ -844,8 +833,9 @@ discard block |
||
| 844 | 833 | public function wps_reload_mini_cart() { |
| 845 | 834 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 846 | 835 | |
| 847 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_mini_cart' ) ) |
|
| 848 | - wp_die(); |
|
| 836 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_mini_cart' ) ) { |
|
| 837 | + wp_die(); |
|
| 838 | + } |
|
| 849 | 839 | |
| 850 | 840 | $wps_cart = new wps_cart(); |
| 851 | 841 | $result = $wps_cart->mini_cart_content( sanitize_title( $_POST['type']) ); |
@@ -925,8 +915,9 @@ discard block |
||
| 925 | 915 | function wps_apply_coupon() { |
| 926 | 916 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 927 | 917 | |
| 928 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_apply_coupon' ) ) |
|
| 929 | - wp_die(); |
|
| 918 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_apply_coupon' ) ) { |
|
| 919 | + wp_die(); |
|
| 920 | + } |
|
| 930 | 921 | |
| 931 | 922 | $status = false; $response = ''; |
| 932 | 923 | $coupon = ( !empty($_POST['coupon_code']) ) ? wpshop_tools::varSanitizer( $_POST['coupon_code']) : null; |
@@ -938,12 +929,10 @@ discard block |
||
| 938 | 929 | $this->store_cart_in_session($order); |
| 939 | 930 | $status = true; |
| 940 | 931 | $response = '<div class="wps-alert-success">' .__( 'The coupon has been applied', 'wpshop' ). '</div>'; |
| 941 | - } |
|
| 942 | - else { |
|
| 932 | + } else { |
|
| 943 | 933 | $response = '<div class="wps-alert-error">' .$result['message']. '</div>'; |
| 944 | 934 | } |
| 945 | - } |
|
| 946 | - else { |
|
| 935 | + } else { |
|
| 947 | 936 | $response = '<div class="wps-alert-error">'.__( 'A coupon code is required', 'wpshop'). '</div>'; |
| 948 | 937 | } |
| 949 | 938 | echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
@@ -957,8 +946,9 @@ discard block |
||
| 957 | 946 | public static function wps_cart_pass_to_step_two() { |
| 958 | 947 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 959 | 948 | |
| 960 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_cart_pass_to_step_two' ) ) |
|
| 961 | - wp_die(); |
|
| 949 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_cart_pass_to_step_two' ) ) { |
|
| 950 | + wp_die(); |
|
| 951 | + } |
|
| 962 | 952 | |
| 963 | 953 | $status = false; $response = ''; |
| 964 | 954 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
@@ -968,8 +958,7 @@ discard block |
||
| 968 | 958 | $response = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step='.$step; |
| 969 | 959 | $response = apply_filters('wps_extra_signup_actions', $response); |
| 970 | 960 | $status = true; |
| 971 | - } |
|
| 972 | - else { |
|
| 961 | + } else { |
|
| 973 | 962 | $response = '<div class="wps-alert-error">' .__( 'An error was occured, please retry later or contact the website administrator', 'wpshop' ). '</div>'; |
| 974 | 963 | } |
| 975 | 964 | echo json_encode( array( 'status' => $status, 'response' => $response)); |
@@ -983,8 +972,9 @@ discard block |
||
| 983 | 972 | function wps_empty_cart() { |
| 984 | 973 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 985 | 974 | |
| 986 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_empty_cart' ) ) |
|
| 987 | - wp_die(); |
|
| 975 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_empty_cart' ) ) { |
|
| 976 | + wp_die(); |
|
| 977 | + } |
|
| 988 | 978 | |
| 989 | 979 | |
| 990 | 980 | $this->empty_cart(); |