_Product_design_list[0]->_personalize); if ($order->_Product_design_list[0]->_status == "In Cart" /*&& count($order->_Product_design_list[0]->_personalize) == 0*/) { echo '
Shopping Cart
'; function getshirtlistprice($f_personalize_colors, $b_personalize_colors,$numshirtpersonalize, $type, $db) { $sql = "SELECT _name, _number, _name_number, _strokecolor FROM `Price Personalize` WHERE $numshirtpersonalize BETWEEN `Range_From` and `Range_To`"; $result = mysqli_query($db, $sql); $price = 0.00; $_strokecolor = 0; while($row = $result->fetch_assoc()) { switch ($type) { case 'name only': $price = doubleval($row["_name"]); break; case 'number only': $price = doubleval($row["_number"]); break; case 'both': $price = doubleval($row["_name_number"]); break; default: $price = 0.00; break; } $_strokecolor = doubleval($row["_strokecolor"]); } if (count($numshirtpersonalize > 0)) { for ($i=0; $i < count($f_personalize_colors) ; $i++) { if (strrpos($f_personalize_colors[$i]->type, "stroke") === 0) { $price += $_strokecolor; } } for ($i=0; $i < count($b_personalize_colors) ; $i++) { if (strrpos($b_personalize_colors[$i]->type, "stroke") === 0) { $price += $_strokecolor; } } } return $price; } function Calc_price_shirt($size,$quantity,$numcolors,$color,$idproduct,$db,$numshirtpersonalize, $type) { $price = 0.0; $amnt = $quantity ; $f_colors = count($numcolors[0]->_ColorList)/* - count($numcolors[0]->_ColorPersonalizeList)*/ ; $r_colors = count($numcolors[1]->_ColorList) ; $b_colors = count($numcolors[2]->_ColorList)/* - count($numcolors[2]->_ColorPersonalizeList)*/ ; $l_colors = count($numcolors[3]->_ColorList) ; $f_price = 0.0; $r_price = 0.0; $b_price = 0.0; $l_price = 0.0; if ($f_colors + $r_colors + $b_colors + $l_colors < 1) { $price = 0.00; } else { $mayor = $f_colors; $side = "F"; if($r_colors > $mayor) { $mayor = $r_colors; $side = "R"; } if($b_colors > $mayor) { $mayor = $b_colors; $side = "B"; } if($l_colors > $mayor) { $mayor = $l_colors; $side = "L"; } if( $side == "F" /*$f_colors > $r_colors && $f_colors > $b_colors && $f_colors > $l_colors*/) { $f_price = calc_price($f_colors,$db,$amnt) ; //rest of prices calc with discount here $r_price = calc_price($r_colors,$db,$amnt) * calc_discount($r_colors,$db,$amnt) ; $b_price = calc_price($b_colors,$db,$amnt) * calc_discount($b_colors,$db,$amnt) ; $l_price = calc_price($l_colors,$db,$amnt) * calc_discount($l_colors,$db,$amnt) ; } else if($side == "R"/*$r_colors > $b_colors && $r_colors > $l_colors*/) { $r_price = calc_price($r_colors,$db,$amnt) ; //rest of prices calc with discount here $f_price = calc_price($f_colors,$db,$amnt) * calc_discount($f_colors,$db,$amnt) ; $b_price = calc_price($b_colors,$db,$amnt) * calc_discount($b_colors,$db,$amnt) ; $l_price = calc_price($l_colors,$db,$amnt) * calc_discount($l_colors,$db,$amnt) ; } else if($side == "B"/*$b_colors > $l_colors*/) { $b_price = calc_price($b_colors,$db,$amnt) ; //rest of prices calc with discount here $f_price = calc_price($f_colors,$db,$amnt) * calc_discount($f_colors,$db,$amnt) ; $r_price = calc_price($r_colors,$db,$amnt) * calc_discount($r_colors,$db,$amnt) ; $l_price = calc_price($l_colors,$db,$amnt) * calc_discount($l_colors,$db,$amnt) ; } else { $l_price = calc_price($b_colors,$db,$amnt) ; //rest of prices calc with discount here $f_price = calc_price($f_colors,$db,$amnt) * calc_discount($f_colors,$db,$amnt) ; $r_price = calc_price($r_colors,$db,$amnt) * calc_discount($r_colors,$db,$amnt) ; $b_price = calc_price($b_colors,$db,$amnt) * calc_discount($b_colors,$db,$amnt) ; } /*if($size=="NB" || $size=="0M" || $size=="3M" || $size=="6M" || $size=="12M" || $size=="18M" || $size=="24M") { if ($color == "White") { $size_price_col = "_INFANTWHITE"; } else { $size_price_col = "_INFANT"; } } else if($size=="2T" || $size=="3T" || $size=="4T" || $size=="5T" || $size=="5_6" || $size=="6T" || $size=="7") { if ($color == "White") { $size_price_col = "_TODDLERWHITE"; } else { $size_price_col = "_TODDLER"; } } else if ($size =="YXS" || $size=="YS" || $size=="YM" || $size=="YL" || $size=="YXL") { if ($color == "White") { $size_price_col = "_YOUTHWHITE"; } else { $size_price_col = "_YOUTH"; } } else if($size=="XS" || $size=="S" || $size=="M" || $size=="L" || $size=="XL") { if ($color == "White") { $size_price_col = "_ADULTWHITE"; } else { $size_price_col = "_ADULT"; } } else if($size=="2XL") { if ($color == "White") { $size_price_col = "_2xlWHITE"; } else { $size_price_col = "_2xl"; } } else if($size=="3XL") { if ($color == "White") { $size_price_col = "_3xlWHITE"; } else { $size_price_col = "_3xl"; } } else if($size=="4XL") { if ($color == "White") { $size_price_col = "_4xlWHITE"; } else { $size_price_col = "_4xl"; } } else if($size=="5XL") { if ($color == "White") { $size_price_col = "_5xlWHITE"; } else { $size_price_col = "_5xl"; } } $sql = "SELECT p.`".$size_price_col."` FROM product p WHERE p.Id = $idproduct"; $result = mysqli_query($db, $sql); while($row = $result->fetch_assoc()) { $price = number_format(($f_price+$r_price+$b_price+$l_price+ $row[$size_price_col]), 2, '.', ''); }*/ $element = $size; $categoryprice = ""; if($element=="NB-0M" || $element=="0M" || $element=="3M" || $element=="6M" || $element=="12M" || $element=="18M" || $element=="24M") { if ($color == "White") { $categoryprice = 'Infant_White'; } else { $categoryprice = 'Infant_Colors'; } } else if($element=="2T" || $element=="3T" || $element=="4T" || $element=="5T" || $element=="5_6" || $element=="6T" || $element=="7") { if ($color == "White") { $categoryprice = 'Toddler_White'; } else { $categoryprice = 'Toddler_Colors'; } } else if ($element =="YXS" || $element=="YS" || $element=="YM" || $element=="YL" || $element=="YXL") { if ($color == "White") { $categoryprice = 'Youth_White'; } else { $categoryprice = 'Youth_Colors'; } } else if($element=="XS" || $element=="S" || $element=="M" || $element=="L" || $element=="XL") { if ($color == "White") { $categoryprice = 'Adult_White'; } else { $categoryprice = 'Adult_Colors'; } } else if($element=="2XL") { if ($color == "White") { $categoryprice = '2XL_White'; } else { $categoryprice = '2XL_Colors'; } } else if($element=="3XL") { if ($color == "White") { $categoryprice = '3XL_White'; } else { $categoryprice = '3XL_Colors'; } } else if($element=="4XL") { if ($color == "White") { $categoryprice = '4XL_White'; } else { $categoryprice ='4XL_Colors'; } } else if($element=="5XL") { if ($color == "White") { $categoryprice = '5XL_White'; } else { $categoryprice = '5XL_Colors'; } } //$sql=" SELECT `".$categoryprice."` FROM `Pricing Shirt Table` WHERE idproduct = '".$idproduct."' AND (SELECT CASE WHEN MAX(Range_To) < $amnt THEN MAX(Range_To) ELSE $amnt END AS Range_Max FROM `Pricing Shirt Table` WHERE idproduct = '".$idproduct."') BETWEEN Range_From AND Range_To"; $sql ="SELECT `".$categoryprice."` FROM `Pricing Shirt Table` WHERE $amnt BETWEEN `Range_From` and `Range_To` and idproduct='".$idproduct."';"; $result = mysqli_query($db, $sql); while($row = $result->fetch_assoc()) { $price = number_format(($f_price+$r_price+$b_price+$l_price+ $row[$categoryprice]), 2, '.', ''); } } //$personalizeprice = getshirtlistprice($numcolors[0]->_ColorPersonalizeList, $numcolors[2]->_ColorPersonalizeList,$numshirtpersonalize, $type, $db); //echo "price: $price; personalizeprice: $personalizeprice;"; //return $price + $personalizeprice; return $price; } function calc_price($numcolors,$db,$amnt) { $price = 0.0; $color_col = ""; if($numcolors > 0) { switch ($numcolors) { case 0: $color_col = "0_Color"; break; case 1: $color_col = "1_Color"; break; case 2: $color_col = "2_Color"; break; case 3: $color_col = "3_Color"; break; case 4: $color_col = "4_color"; break; case 5: $color_col = "5_Color"; break; case 6: $color_col = "6_Color"; break; case 7: $color_col = "7_Color"; break; default: $color_col = "8_Color"; break; } $sql = "SELECT `".$color_col."` FROM `Pricing Table` WHERE $amnt BETWEEN `Range_From` and `Range_To`"; $result = mysqli_query($db, $sql); while($row = $result->fetch_assoc()) { $price = doubleval($row[$color_col]); } } return $price; } function calc_discount($numcolors,$db,$amnt) { $discount = 0.5; if($numcolors > 0) { switch ($numcolors) { case 0: $color_col = "0_Color"; break; case 1: $color_col = "1_Color"; break; case 2: $color_col = "2_Color"; break; case 3: $color_col = "3_Color"; break; case 4: $color_col = "4_color"; break; case 5: $color_col = "5_Color"; break; case 6: $color_col = "6_Color"; break; case 7: $color_col = "7_Color"; break; default: $color_col = "8_Color"; break; } $sql ="SELECT `".$color_col."` FROM `Price Discount Table` WHERE $amnt BETWEEN `Range_From` and `Range_To`"; $result = mysqli_query($db, $sql); while($row = $result->fetch_assoc()) { $discount = 1- (doubleval($row[$color_col])/100); } } return $discount; } if (isset($_SESSION['Order'])) { $order = json_decode($_SESSION['Order']); for ($j = 0; $j < count($order->_Product_design_list); $j++) { if ($order->_Product_design_list[$j]->_status == "In Cart" && count($order->_Product_design_list[$j]->_design->_design_name) > 0) { $total= 0; echo '
Design Name: '.explode('_',$order->_Product_design_list[$j]->_design->_design_name)[1].'
_Product_design_list[$j]->_design->_sideList[0]->_design_product_image == "") ? "style='display:none;'": "").'> .
_Product_design_list[$j]->_design->_sideList[1]->_design_product_image == "") ? "style='display:none;'": "").'> .
.
.
'; echo ' '; echo'
_Product_design_list[$j]->_design->_design_name."'".';" class="submit-btn-1 btn-hover-1" style="float:right; padding:6px; margin:6px;"> Edit Design
'. $order->_Product_design_list[$j]->_Product->Parent .'

Brand: '. $order->_Product_design_list[$j]->_Product->Brand .'

Color: '.$order->_Product_design_list[$j]->_Product->Colors.'

'; //looping through sizes //this is to keep the sizes in order when a size is being removed of added $size_order = array("1"=>"NB","2"=>"0M","3"=>"3M","4"=>"6M","5"=>"12M","6"=>"18M","7"=>"24M","8"=>"2T","9"=>"3T","10"=>"4T","11"=>"5T","12"=>"5_6","13"=>"6T","14"=>"7","15"=>"YXS" ,"16"=>"YS","17"=>"YM","18"=>"YL","19"=>"YXL","20"=>"XS","21"=>"S","22"=>"M","23"=>"L","24"=>"XL","25"=>"2XL","26"=>"3XL","27"=>"4XL","28"=>"5XL"); $quantity = 0; for ($k=0; $k < count($order->_Product_design_list[$j]->_sizeList); $k++) { if($order->_Product_design_list[$j]->_sizeList[$k]->_quantity > 0) { $price = 0.00; $quantity = intval($order->_Product_design_list[$j]->_sizeList[$k]->_quantity); //storing the size of this row in a variable $current_size = strtoupper($order->_Product_design_list[$j]->_sizeList[$k]->_size_name); $price = Calc_price_shirt($current_size,$order->_Product_design_list[$j]->_num_shirts,$order->_Product_design_list[$j]->_design->_sideList,$order->_Product_design_list[$j]->_Product->Colors,$order->_Product_design_list[$j]->_Product->Id,$db,count($order->_Product_design_list[$j]->_personalize), $order->_Product_design_list[$j]->_personalizetype); //print_r("size: ".$current_size."shirt_price:".$price." quantity: ".$quantity." total:".$price*$quantity); $subtotal+= number_format(($price*$quantity), 2, '.', ''); //The class is $j because $j keep track of the specific product_design we are looking at. //The id is $j_(index of the size in the array) to keep tack of not only which product_design, //but also the place of this size in our size_order list. echo ''; echo ' '; } } $total+= number_format($subtotal, 2, '.', ''); echo '
size price Quantity total remove
'.$current_size.' $'.number_format($price, 2, '.', '')/*$order->_Product_design_list[$j]->_price_per_shirt*/.'
_Product_design_list[$j]->_sizeList[$k]->_size_name.'" name="qtybutton_'.$j."_".$order->_Product_design_list[$j]->_sizeList[$k]->_size_name.'" class="cart-plus-minus-box quantity size_details quantity_'.$j.'" onchange="updateAfterAdd(`'.$j."_".$order->_Product_design_list[$j]->_sizeList[$k]->_size_name.'`);" onclick="updateAfterAdd(`'.$j."_".$order->_Product_design_list[$j]->_sizeList[$k]->_size_name.'`);" >
$_Product_design_list[$j]->_sizeList[$k]->_size_name.'" class="item_total_'.$j.'">'.number_format($price*$quantity, 2, '.', '') .' _Product_design_list[$j]->_sizeList[$k]->_size_name.'`); $(this).closest(`tr`).remove();" style="cursor:pointer;">
'; //add size component echo '
Order SubTotal $'.number_format($subtotal, 2, '.', '').'
'; echo'
Add more sizes
'; $sizeproductdesign = array(); for ($pos=0; $pos < count($order->_Product_design_list[$j]->_sizeList) ; $pos++) { if ($order->_Product_design_list[$j]->_sizeList[$pos]->_quantity > 0) { array_push($sizeproductdesign, strtoupper($order->_Product_design_list[$j]->_sizeList[$pos]->_size_name)); } } $sizesenables = explode(" ", $order->_Product_design_list[$j]->_Product->Sizes); $sizesenables = array_diff($sizesenables, $sizeproductdesign); echo '
Select Size :
'; echo'

'; if (count($order->_Product_design_list[0]->_personalize) > 0) { echo '
Design Name: '.explode('_',$order->_Product_design_list[$j]->_design->_design_name)[1].'
'; echo ' '; echo'
'; //$quantity = 0; //var_dump($order->_Product_design_list[$j]->_personalizetype); $shirtpersonalizeprice = getshirtlistprice($order->_Product_design_list[$j]->_design->_sideList[0]->_ColorPersonalizeList, $order->_Product_design_list[$j]->_design->_sideList[2]->_ColorPersonalizeList, count($order->_Product_design_list[$j]->_personalize), $order->_Product_design_list[$j]->_personalizetype, $db); for ($k=0; $k < count($order->_Product_design_list[$j]->_personalize); $k++) { echo ' '; $subtotalpersonalize +=$shirtpersonalizeprice; } echo ' '; $total+= number_format($subtotalpersonalize, 2, '.', ''); echo '
Name Number Size total
'.$order->_Product_design_list[$j]->_personalize[$k]->name.' '.$order->_Product_design_list[$j]->_personalize[$k]->number.' '.$order->_Product_design_list[$j]->_personalize[$k]->size_name.' '.number_format(($shirtpersonalizeprice), 2, '.', '').'
_Product_design_list[$j]->_design->_design_name."'".';" class="submit-btn-1 btn-hover-1" style="float:right; padding:6px; margin:6px;"> Edit Design
'; //add size component echo '
Order SubTotal $'.number_format($subtotalpersonalize, 2, '.', '').'
'; echo'

'; } } else { echo '
Design Name: '.explode('_',$order->_Product_design_list[$j]->_design->_design_name)[1].'
'; echo ' '; echo'
'; //$quantity = 0; //var_dump($order->_Product_design_list[$j]->_personalizetype); $shirtpersonalizeprice = getshirtlistprice($order->_Product_design_list[$j]->_design->_sideList[0]->_ColorPersonalizeList, $order->_Product_design_list[$j]->_design->_sideList[2]->_ColorPersonalizeList, count($order->_Product_design_list[$j]->_personalize), $order->_Product_design_list[$j]->_personalizetype, $db); for ($k=0; $k < count($order->_Product_design_list[$j]->_personalize); $k++) { echo ' '; $subtotalpersonalize +=$shirtpersonalizeprice; } echo ' '; $total+= number_format($subtotalpersonalize, 2, '.', ''); echo '
Name Number Size total
'.$order->_Product_design_list[$j]->_personalize[$k]->name.' '.$order->_Product_design_list[$j]->_personalize[$k]->number.' '.$order->_Product_design_list[$j]->_personalize[$k]->size_name.' '.number_format(($shirtpersonalizeprice), 2, '.', '').'
_Product_design_list[$j]->_design->_design_name."'".';" class="submit-btn-1 btn-hover-1" style="float:right; padding:6px; margin:6px;"> Edit Design
'; //add size component echo '
Order SubTotal $'.number_format($subtotalpersonalize, 2, '.', '').'
'; echo'

'; } } } echo '
'; //$order->_subtotal = $total; /* $total = 0; for ($posttotal = 0; $posttotal < count($order->_Product_design_list); $posttotal++) { $total+= $order->_Product_design_list[$posttotal]->_total; }*/ $order->_subtotal = $total; if ($order->_discount > 0) { $order->_tax = number_format((((($order->_subtotal-$order->_discount)+$order->_shipping_cost)* 8.25)/100), 2, '.', ''); } else { $order->_tax = number_format((((($order->_subtotal)+$order->_shipping_cost)* 8.25)/100), 2, '.', ''); } $order->_total = $order->_subtotal + $order->_tax; echo '
Estimated Total $'.number_format( $order->_subtotal, 2, '.', '').'

'; echo'
Shipping Method
'; if (isset($_SESSION['user'])) { echo '
Billing Info
'; $sqladdres = "SELECT DISTINCT fulladdress,billingStreet,billingCity,billingState,billingZip FROM (SELECT CONCAT(c.billingStreet,',',c.billingCity,',',c.billingState,',',c.billingZip) as fulladdress, c.* FROM Customer c WHERE c.username = '".$_SESSION['user']['Username']."') as info"; $resultaddres = $db->query($sqladdres); $quantityaddres = mysqli_num_rows($resultaddres); $totaladdres = 0; if ($quantityaddres > 0) { while ($rowaddres = $resultaddres->fetch_array(MYSQLI_ASSOC) ) { /* echo ' ';*/ if ( $totaladdres == 0) { $Id_Customer = $rowaddres['Id_Customer']; $billingStreet = $rowaddres['billingStreet']; $billingCity = $rowaddres['billingCity']; $billingState = $rowaddres['billingState']; $billingZip = $rowaddres['billingZip']; } $totaladdres++; } echo'
'; } else { echo'
'; } echo'
Shipping Method

Guaranteed by ||

FREE

Guaranteed by ||

Credit Card Info
Shipping Address
'; } else { echo '
Billing Info
Shipping Method

Guaranteed by ||

FREE

Guaranteed by ||

Credit Card Info
Shipping Address
'; } echo '
Order Total
Subtotal: $'. number_format($order->_subtotal, 2, '.', '').'
Discount: $'. number_format($order->_discount, 2, '.', '').'
Standard Shipping $0.00
Tax: $'. number_format($order->_tax, 2, '.', '').'
Total: $'. number_format($order->_total, 2, '.', '').'
'; if (isset($_SESSION['Order'])) { $subtotal = 0; $total = 0; $order = json_decode($_SESSION['Order']); echo '
Thank you. Your order has been received.
  • Order Number: '.$order->_Order_Number.'
order Details
Subtotal: $'. number_format($order->_subtotal, 2, '.', '').'
Discount: $'. number_format($order->_discount, 2, '.', '').'
Standard Shipping $0.00
Tax: $'. number_format($order->_tax, 2, '.', '').'
Total: $'. number_format($order->_total, 2, '.', '').'
'; } echo'
'; if (isset($_SESSION['user'])) { echo ''; } else { echo ''; } echo'
'; } else { echo '

"There are currently no items in your cart"


Browse our
Product Page
or
Start Designing now
'; } } else { echo '

"There are currently no items in your cart"


Browse our
Product Page
or
Start Designing now
'; } ?>
l o a d i n g