array( 'code'=>$id_code, 'sku'=>$added_sku, 'size'=>$size, 'length'=>$length, 'width'=>$width, 'height'=>$height, 'weight'=>$weight, 'name'=>$name, 'price'=>$sku_price, 'currency'=>$country_cur, 'inregion'=>$in_region, 'outregion'=>$out_region, 'oneday'=>$one_day, 'twoday'=>$two_day, 'quantity'=>$quantity, 'image'=>$image, 'slogan'=>$slogan, 'link'=>$link) ); if (isset($_GET['addtocart']) && $_GET['addtocart']!="") { if(!empty($_SESSION['shopping_cart'])) { foreach( $_SESSION['shopping_cart'] as $key => $value ) { if( $_GET['addtocart']=== $key) { $_SESSION['shopping_cart'][$key]['quantity'] = $_SESSION['shopping_cart'][$key]['quantity'] + $_POST['product_quantity']; $status = "
Product quantity updated
"; $cartArray = ''; break; } } if($_SESSION['shopping_cart']!=='' && $_GET['addtocart']!==$key){ $_SESSION["shopping_cart"] = array_merge($_SESSION["shopping_cart"],$cartArray); $status = "
Product added to cart
"; $cartArray = ''; } } if ($_SESSION['shopping_cart']=='') { $_SESSION["shopping_cart"] = $cartArray; $status = "
Product added to cart
"; $cartArray = ''; } } //END ADD TO CART TRIGGER } $status=""; if (isset($_POST['product_sku']) && $_POST['product_sku']!=""){ $code = $_POST['product_code']; if(isset($_POST['product_quantity'])) { $quantity = $_POST['product_quantity']; } if(isset($_POST['quantity'])) { $quantity = $_POST['quantity']; } $form_name = $_POST['product_name']; $added_sku = $_POST['product_sku']; if(isset($_POST['product_price'])) { $sku_price = $_POST['product_price']; } if(isset($_POST['sku_price'])) { $sku_price = $_POST['sku_price']; } $result = mysqli_query($conn,"SELECT * FROM `product_skus` WHERE `product_sku`='$added_sku'"); while($row = mysqli_fetch_assoc($result)) { $in_region = $row['in_region']; $out_region = $row['out_region']; $one_day = $row['1_day']; $two_day = $row['2_day']; $length = $row['sku_length']; $width = $row['sku_width']; $height = $row['sku_height']; $weight = $row['sku_weight']; $image = $row['sku_image']; $size = $row['sku_size']; $id_code = $row['product_code']; } $result2 = mysqli_query($conn,"SELECT * FROM `product_parents` WHERE `product_code`='$code'"); $row2 = mysqli_fetch_assoc($result2); $name = $form_name; $slogan = $row2['product_slogan']; $link = $row2['permalink']; $cartArray = array( $added_sku=>array( 'code'=>$id_code, 'sku'=>$added_sku, 'size'=>$size, 'length'=>$length, 'width'=>$width, 'height'=>$height, 'weight'=>$weight, 'name'=>$name, 'price'=>$sku_price, 'currency'=>$country_cur, 'inregion'=>$in_region, 'outregion'=>$out_region, 'oneday'=>$one_day, 'twoday'=>$two_day, 'quantity'=>$quantity, 'image'=>$image, 'slogan'=>$slogan, 'link'=>$link) ); if (isset($_POST['action']) && $_POST['action']=="remove"){ if(!empty($_SESSION["shopping_cart"])) { foreach($_SESSION["shopping_cart"] as $key => $value) { if($_POST["product_sku"]=== $key){ unset($_SESSION["shopping_cart"][$key]); $status = "
Product is removed from your cart!
"; } if($key===''){ unset($_SESSION["shopping_cart"]); $status = "
Product is removed from your cart!
"; } if(empty($_SESSION["shopping_cart"])) unset($_SESSION["shopping_cart"]); $status = "
Product is removed from your cart!
"; } } } if (isset($_POST['action']) && $_POST['action']=="change"){ foreach($_SESSION["shopping_cart"] as &$value){ if($value['sku'] === $_POST["product_sku"]){ $value['quantity'] = $_POST["quantity"]; $status = "
Product quantity has been updated
"; break; // Stop the loop after we've found the product } } } if (isset($_POST['action']) && $_POST['action']=="additem") { if(!empty($_SESSION['shopping_cart'])) { foreach( $_SESSION['shopping_cart'] as $key => $value ) { if( $_POST['product_sku']=== $key) { $_SESSION['shopping_cart'][$key]['quantity'] = $_SESSION['shopping_cart'][$key]['quantity'] + $_POST['product_quantity']; $status = "
Product quantity updated
"; $cartArray = ''; break; } } if($_SESSION['shopping_cart']!=='' && $_POST['product_sku']!==$key){ $_SESSION["shopping_cart"] = array_merge($_SESSION["shopping_cart"],$cartArray); $status = "
Product added to cart
"; $cartArray = ''; } } if (empty($_SESSION['shopping_cart'])) { $_SESSION["shopping_cart"] = $cartArray; $status = "
Product added to cart
"; $cartArray = ''; } } } if(isset($_POST['action'])) { if(!empty($_SESSION['shopping_cart']) && $_POST['action']=="") { foreach( $_SESSION['shopping_cart'] as $key => $value ) { if ($value['currency']!== $country_cur) { unset($_SESSION["shopping_cart"]); } } } } if(isset($_POST['error']) && !$_POST['error']=="") { $status = "
".$_POST['error']."
"; } if(isset($_POST['error']) && $_POST['error']==="cardnumber") { $status = "
The credit card supplied appears to be invalid.
"; } if(isset($_POST['error']) && $_POST['error']==="address") { $status = "
".$_POST['error']."
"; } if(isset($_POST['error']) && $_POST['error']==="PICK UP CARD") { $status = "
The credit card supplied has been reported lost or stolen by the card issuer. Your IP address and information have been retained.
"; } if(isset($_POST['error']) && $_POST['error']==="EXPIRED CARD") { $status = "
The credit card supplied is expired.
"; } if(isset($_POST['error']) && $_POST['error']==="SERV NOT ALLOWED") { $status = "
The credit card supplied is not authorized for this transaction. A business credit card may prevent personal transactions.
"; } if(isset($_POST['error']) && $_POST['error']==="DECLINED CVV2") { $status = "
The CVV2 Code entered does not match what is on the card. Please re-enter the CVV2 code and try again.
"; } if(isset($_POST['error']) && $_POST['error']==="DECLINED") { $status = "
The credit card supplied declined the transaction. Please try again.
"; } if(isset($_POST['account']) && $_POST['account']==="username") { $status = "
User does not exist. Please try again.
"; } if(isset($_POST['account']) && $_POST['account']==="password") { $status = "
Password was incorrect. Please try again.
"; } if(isset($_POST['account']) && $_POST['account']==="server") { $status = "
There was a server error. Please try again.
"; } if(isset($_POST['account']) && $_POST['account']==="reactivated") { $status = "
Account reactivated. Please log in.
"; } // Print array contents //print_r($_SESSION['shopping_cart']); if(isset($_SESSION['wwel_customer_id'])) { if ($_SESSION['wwel_customer_id'] != NULL) { }}; if(isset($_SESSION['shopping_cart'])) { $cart_count = count(array_keys($_SESSION["shopping_cart"])); } else { $cart_count = 0; } ?>