Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset($_GET['add_to_cart'])) {
- $the_product_id = mysqli_real_escape_string($connection, $_GET['add_to_cart']);
- $query = "SELECT * FROM products WHERE product_id = {$the_product_id} AND product_status = 'published'";
- $select_product_for_cart = mysqli_query($connection, $query);
- while ($row = mysqli_fetch_assoc($select_product_for_cart)) {
- $product_id = $row['product_id'];
- $product_name_ro = $row['product_name_ro'];
- $product_name_en = $row['product_name_en'];
- $product_name_fr = $row['product_name_fr'];
- $product_price_ron = $row['product_price_ron'];
- $product_price_dollar = $row['product_price_dolar'];
- $product_price_euro = $row['product_price_euro'];
- $size = "l";
- $color = "red";
- $quantity = 1;
- if (isset($_GET['lang'])) {
- $the_lang = mysqli_real_escape_string($connection, $_GET['lang']);
- if ($the_lang == 'ro') {
- $product_name = $product_name_ro;
- } else if ($the_lang == 'en') {
- $product_name = $product_name_en;
- } else if ($the_lang == 'fr') {
- $product_name = $product_name_fr;
- }
- } else {
- $product_name = $product_name_ro;
- }
- if (isset($_GET['coin'])) {
- $the_coin = mysqli_real_escape_string($connection, $_GET['coin']);
- if ($the_coin == 'ron') {
- $price = $product_price_ron;
- $currency = 'RON';
- } else if ($the_coin == 'dollar') {
- $price = $product_price_dollar;
- $currency = '$';
- } else if ($the_coin == 'euro') {
- $price = $product_price_euro;
- $currency = '€';
- }
- } else {
- $price = $product_price_ron;
- $currency = 'RON';
- }
- }
- $total_price = $price * $quantity;
- $_SESSION['cart'][$product_id] = array('product_name' => $product_name, 'coin' => $currency, 'price' => $price, 'total_price' => $total_price, 'size' => $size, 'color' => $color, 'quantity' => $quantity);
- $temp = $_SESSION['cart'];
- array_push($_SESSION['cart'][$product_id], $temp);
- //setcookie($the_product_id, $product_name.",".$currency.",".$price.",".$total_price.",".$size.",".$color.",".$quantity, time() + (86400 * 30), "/");
- header("Location: ".$_SERVER['HTTP_REFERER']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement