/** * This function is used to show the order confirmation * * @param string $message contains both error messages and values * * @return string */ function showOrderConfirmation($message = '') { if ($_SESSION['user_id'] != '' && $_SESSION['mycart'] == '') { $_SESSION['digitalproducts'] = 0; Core_CAddCart::insertShipping(); $cartid = Core_CAddCart::getCartIdOfUser(); $taxarray = Core_CAddCart::getTaxSettings(); if ($cartid != '') { $sql3 = "select cou_code,cou_name from country_table"; $obj3 = new Bin_Query(); $obj3->executeQuery($sql3); $sql = "SELECT min(product_qty) as product_qty from shopping_cart_products_table where cart_id=" . $cartid; $query = new Bin_Query(); $query->executeQuery($sql); $qty = $query->records; $cnt = count($qty); for ($i = 0; $i <= $cnt; $i++) { $qty[$i]['product_qty']; if ($qty[$i]['product_qty'] == 1) { $sql = 'SELECT pt.title, pt.model, pt.product_id,pt.digital, pt.brand, shopping_cart_products_table.shipping_cost AS shipingamount, pt.sku, pt.msrp as msrp1,shopping_cart_products_table.product_unit_price AS msrp, pt.image, pt.thumb_image, pinv.soh, shopping_cart_products_table. * , shopping_cart_table. * FROM ( products_table pt INNER JOIN shopping_cart_products_table ON pt.product_id = shopping_cart_products_table.product_id ) LEFT JOIN shopping_cart_table ON shopping_cart_products_table.cart_id = shopping_cart_table.cart_id INNER JOIN product_inventory_table AS pinv ON pinv.product_id = shopping_cart_products_table.product_id WHERE shopping_cart_table.user_id =' . $_SESSION['user_id']; $query = new Bin_Query(); $query->executeQuery($sql); $flag = $query->totrows; for ($ii1 = 0; $ii1 < $flag; $ii1++) { if ($this->getVariationDetailsForProduct($query->records[$ii1]['product_id'], $query->records[$ii1]['variation_id'])) { $query->records[$ii1] = array_merge($query->records[$ii1], $this->getVariationDetailsForProduct($query->records[$ii1]['product_id'], $query->records[$ii1]['variation_id'])); $query->records[$ii1]['shipingamount'] = $query->records[$ii1]['shipping_cost'] * $query->records[$ii1]['product_qty']; } if (Core_CAddCart::isDigitalProduct($query->records[$ii1]['product_id'])) { $_SESSION['digitalproducts'] = $_SESSION['digitalproducts'] + 1; } } if ($_SESSION['gift'] != '') { for ($g = 0; $g < count($_SESSION['gift']); $g++) { /*Generate the gift Code */ $characters = '4'; $possible = '1234567890'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1); $i++; } $code = "AJGC" . $code; $sqlgift = "INSERT INTO gift_voucher_table(cart_id, \tgift_product_id,recipient_name,recipient_email,name,email, \tcertificate_theme,message,gift_code)VALUES('" . $cartid . "','" . $_SESSION['gift'][$g]['proid'] . "','" . $_SESSION['gift'][$g]['rname'] . "','" . $_SESSION['gift'][$g]['remail'] . "','" . $_SESSION['gift'][$g]['name'] . "','" . $_SESSION['gift'][$g]['email'] . "','" . $_SESSION['gift'][$g]['gctheme'] . "','" . $_SESSION['gift'][$g]['message'] . "','" . $code . "')"; $objgift = new Bin_Query(); $objgift->updateQuery($sqlgift); } } if ($flag == 0) { return '<div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> ' . Core_CLanguage::_(NO_PRODUCTS_AVAILABLE_IN_YOUR_CART) . ' </div>'; } else { return Display_DAddCart::showOrderConfirmation($query->records, $obj3->records, $taxarray, $message); } } else { $query = new Bin_Query(); $sql = 'SELECT pt.title, pt.model, pt.product_id, pt.brand,pt.digital, shopping_cart_products_table.shipping_cost as shipingamount, pt.sku, shopping_cart_products_table.product_unit_price AS msrp, pt.msrp as msrp1, pt.image, pt.thumb_image, pinv.soh,shopping_cart_products_table. * , shopping_cart_table. * FROM ( products_table pt INNER JOIN shopping_cart_products_table ON pt.product_id = shopping_cart_products_table.product_id ) LEFT JOIN shopping_cart_table ON shopping_cart_products_table.cart_id = shopping_cart_table.cart_id INNER JOIN product_inventory_table AS pinv ON pinv.product_id = shopping_cart_products_table.product_id WHERE shopping_cart_table.user_id =' . $_SESSION['user_id'] . ''; $query->executeQuery($sql); $flag = $query->totrows; for ($ii1 = 0; $ii1 < $flag; $ii1++) { if ($this->getVariationDetailsForProduct($query->records[$ii1]['product_id'], $query->records[$ii1]['variation_id'])) { $query->records[$ii1] = array_merge($query->records[$ii1], $this->getVariationDetailsForProduct($query->records[$ii1]['product_id'], $query->records[$ii1]['variation_id'])); $query->records[$ii1]['shipingamount'] = $query->records[$ii1]['shipping_cost'] * $query->records[$ii1]['product_qty']; } if (Core_CAddCart::isDigitalProduct($query->records[$ii1]['product_id'])) { $_SESSION['digitalproducts'] = $_SESSION['digitalproducts'] + 1; } } if ($_SESSION['gift'] != '') { for ($g = 0; $g < count($_SESSION['gift']); $g++) { /*Generate the gift Code */ $characters = '4'; $possible = '1234567890'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1); $i++; } $code = "AJGC" . $code; $sqlgift = "INSERT INTO gift_voucher_table(cart_id, \tgift_product_id,recipient_name,recipient_email,name,email, \tcertificate_theme,message,gift_code)VALUES('" . $cartid . "','" . $_SESSION['gift'][$g]['proid'] . "','" . $_SESSION['gift'][$g]['rname'] . "','" . $_SESSION['gift'][$g]['remail'] . "','" . $_SESSION['gift'][$g]['name'] . "','" . $_SESSION['gift'][$g]['email'] . "','" . $_SESSION['gift'][$g]['gctheme'] . "','" . $_SESSION['gift'][$g]['message'] . "','" . $code . "')"; $objgift = new Bin_Query(); $objgift->updateQuery($sqlgift); } } if ($flag == 0) { return '<div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> ' . Core_CLanguage::_(NO_PRODUCTS_AVAILABLE_IN_YOUR_CART) . ' </div>'; } else { return Display_DAddCart::showOrderConfirmation($query->records, $obj3->records, $taxarray, $message); } } } $i++; } else { return '<div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> ' . Core_CLanguage::_(NO_PRODUCTS_AVAILABLE_IN_YOUR_CART) . ' </div>'; } } else { if (isset($_SESSION['mycart']) && $_SESSION['mycart'] != '') { Core_CAddCart::insertShipping(); if ($_SESSION['mycart'][0]['cartid'] == '') { $sql = "insert into shopping_cart_table (user_id,cart_date) values ('" . $_SESSION['user_id'] . "','" . date('Y-m-d') . "')"; $query = new Bin_Query(); if ($query->updateQuery($sql)) { $cartid = mysql_insert_id(); } $sql3 = "select cou_code,cou_name from country_table"; $obj3 = new Bin_Query(); $obj3->executeQuery($sql3); foreach ($_SESSION['mycart'] as $key => $val) { $sql = 'SELECT pt.title, pt.model, pt.product_id, pt.brand, pt.shipping_cost AS shipingamount, pt.sku, pt.msrp, pt.image, pt.thumb_image, pinv.soh FROM products_table pt LEFT JOIN product_inventory_table AS pinv ON pt.product_id = pinv.product_id WHERE pt.product_id =' . $val['product_id']; $query = new Bin_Query(); $query->executeQuery($sql); $flag = $query->totrows; $product_unit_prince = $query->records[0]['msrp']; if ($val['variation_id'] != '') { $sqlShip = "SELECT * FROM product_variation_table WHERE variation_id=" . $val['variation_id'] . "\n\t\t\t\t\t\t\t\tAND product_id \t='" . $val['product_id'] . "'"; $objShip = new Bin_Query(); $objShip->executeQuery($sqlShip); $query->records[0]['shipingamount'] = $val['qty'] * $objShip->records[0]['shipping_cost']; $msrp = $objShip->records[0]['msrp']; $original_price = $objShip->records[0]['price']; } else { $query->records[0]['shipingamount'] = $val['qty'] * $query->records[0]['shipingamount']; $defobjj = new Core_CAddCart(); $groupdiscount = $defobjj->getUserGroupDiscount(); $msrp = $product_unit_prince - $product_unit_prince * ($groupdiscount / 100); } if ($_GET['action'] != 'validatecoupon') { $sqlinsert = "insert into shopping_cart_products_table (cart_id,product_id,product_qty, date_added,product_unit_price,shipping_cost,gift_product,variation_id,original_price) values ('" . $cartid . "','" . $val['product_id'] . "','" . $val['qty'] . "','" . date('Y-m-d') . "','" . $msrp . "','" . $query->records[0]['shipingamount'] . "','" . $val['gift'] . "','" . $val['variation_id'] . "','" . $original_price . "')"; $objinsert = new Bin_Query(); $objinsert->updateQuery($sqlinsert); } } $_SESSION['mycart'][0]['cartid'] = $cartid; } $cartid = $_SESSION['mycart'][0]['cartid']; $qty = $_SESSION['mycart']; $cnt = count($qty); foreach ($_SESSION['mycart'] as $key => $val) { $sql = 'SELECT pt.title, pt.model, pt.product_id, pt.brand, pt.shipping_cost AS shipingamount, pt.sku, pt.msrp, pt.image, pt.thumb_image, pinv.soh,scp.cart_id,scp.product_id,scp. product_unit_price,scp.variation_id,scp.product_qty FROM products_table pt LEFT JOIN product_inventory_table AS pinv ON pt.product_id = pinv.product_id LEFT JOIN shopping_cart_products_table AS scp ON scp.product_id = pinv.product_id WHERE pt.product_id =' . $val['product_id'] . ' AND scp.cart_id=' . $cartid; $query = new Bin_Query(); $query->executeQuery($sql); $flag = $query->totrows; for ($ii1 = 0; $ii1 < $flag; $ii1++) { $defaultobj = new Core_CAddCart(); if ($defaultobj->getVariationDetailsForProduct($query->records[$ii1]['product_id'], $query->records[$ii1]['variation_id'])) { $query->records[$ii1] = array_merge($query->records[$ii1], $defaultobj->getVariationDetailsForProduct($query->records[$ii1]['product_id'], $query->records[$ii1]['variation_id'])); $query->records[$ii1]['shipingamount'] = $query->records[$ii1]['shipping_cost'] * $query->records[$ii1]['product_qty']; } } // $product_unit_prince=$query->records[0]['msrp']; // // $query->records[0]['soh']=(int)$query->records[0]['soh']; // $query->records[0]['product_qty']=$val['qty']; // $query->records[0]['shipingamount']=$val['qty']*$query->records[0]['shipingamount']; //calculating shipping cost if ($flag == 0) { return '<div class="alert alert-info"> <button data-dismiss="alert" class="close" type="button">×</button> ' . Core_CLanguage::_(NO_PRODUCTS_AVAILABLE_IN_YOUR_CART) . ' </div>'; } elseif ($query->records[0]['soh'] != 0) { $productarray[] = $query->records[0]; } } if ($_SESSION['gift'] != '') { for ($g = 0; $g < count($_SESSION['gift']); $g++) { /*Generate the gift Code */ $characters = '4'; $possible = '1234567890'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1); $i++; } $code = "AJGC" . $code; $sqlgift = "INSERT INTO gift_voucher_table(cart_id, \tgift_product_id,recipient_name,recipient_email,name,email, \tcertificate_theme,message,gift_code)VALUES('" . $cartid . "','" . $_SESSION['gift'][$g]['proid'] . "','" . $_SESSION['gift'][$g]['rname'] . "','" . $_SESSION['gift'][$g]['remail'] . "','" . $_SESSION['gift'][$g]['name'] . "','" . $_SESSION['gift'][$g]['email'] . "','" . $_SESSION['gift'][$g]['gctheme'] . "','" . $_SESSION['gift'][$g]['message'] . "','" . $code . "')"; $objgift = new Bin_Query(); $objgift->updateQuery($sqlgift); } } return Display_DAddCart::showOrderConfirmation($productarray, $obj3->records, $taxarray, $message); } else { return '<div class="alert alert-info"> <button data-dismiss="alert" class="close" type="button">×</button> ' . Core_CLanguage::_(NO_PRODUCTS_AVAILABLE_IN_YOUR_CART) . ' </div>'; } } }