Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset($_POST['add_to_cart'])) {
- if (isset($_POST['select_size']) && isset($_POST['select_color']) && isset($_POST['select_quantity'])) {
- $size = $_POST['select_size'];
- $color = $_POST['select_color'];
- $quantity = $_POST['select_quantity'];
- 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;
- $the_coin = 'RON';
- } else if ($the_coin == 'dollar') {
- $price = $product_price_dollar;
- $the_coin = '$';
- } else if ($the_coin == 'euro') {
- $price = $product_price_euro;
- $the_coin = '€';
- }
- } else {
- $price = $product_price_ron;
- $the_coin = 'RON';
- }
- }
- $total_price = $price * $quantity;
- $_SESSION['cart'][$product_id] = array('product_name' => $product_name, 'coin' => $the_coin, 'price' => $price, 'total_price' => $total_price, 'size' => $size, 'color' => $color, 'quantity' => $quantity);
- $temp = $_SESSION['cart'];
- array_push($_SESSION['cart'][$product_id], $temp);
- //setcookie($product_id, $product_name.",".$the_coin.",".$price.",".$total_price.",".$size.",".$color.",".$quantity, time() + (86400 * 30), "/");
- /*
- if (isset($_GET['lang'])) {
- $the_lang = mysqli_real_escape_string($connection, $_GET['lang']);
- if ($the_lang == 'ro') {
- setcookie($product_name_ro, $product_id, time() + (86400 * 30), "/");
- } else if ($the_lang == 'en') {
- setcookie($product_name_en, $product_id, time() + (86400 * 30), "/");
- } else if ($the_lang == 'fr') {
- setcookie($product_name_fr, $product_id, time() + (86400 * 30), "/");
- }
- } else {
- }
- */
- header("Location: ".$_SERVER['HTTP_REFERER']);
- and html
- <button class="btn btn-primary" type="submit" name="add_to_cart"><?php echo add_to_cart; ?></button>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement