Advertisement
Guest User

Untitled

a guest
Nov 15th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. if (isset($_GET['add_to_cart'])) {
  2. $the_product_id = mysqli_real_escape_string($connection, $_GET['add_to_cart']);
  3.  
  4. $query = "SELECT * FROM products WHERE product_id = {$the_product_id} AND product_status = 'published'";
  5. $select_product_for_cart = mysqli_query($connection, $query);
  6.  
  7. while ($row = mysqli_fetch_assoc($select_product_for_cart)) {
  8. $product_id = $row['product_id'];
  9. $product_name_ro = $row['product_name_ro'];
  10. $product_name_en = $row['product_name_en'];
  11. $product_name_fr = $row['product_name_fr'];
  12. $product_price_ron = $row['product_price_ron'];
  13. $product_price_dollar = $row['product_price_dolar'];
  14. $product_price_euro = $row['product_price_euro'];
  15.  
  16. $size = "l";
  17. $color = "red";
  18. $quantity = 1;
  19.  
  20.  
  21. if (isset($_GET['lang'])) {
  22. $the_lang = mysqli_real_escape_string($connection, $_GET['lang']);
  23.  
  24. if ($the_lang == 'ro') {
  25. $product_name = $product_name_ro;
  26. } else if ($the_lang == 'en') {
  27. $product_name = $product_name_en;
  28. } else if ($the_lang == 'fr') {
  29. $product_name = $product_name_fr;
  30. }
  31. } else {
  32. $product_name = $product_name_ro;
  33. }
  34.  
  35.  
  36. if (isset($_GET['coin'])) {
  37. $the_coin = mysqli_real_escape_string($connection, $_GET['coin']);
  38.  
  39. if ($the_coin == 'ron') {
  40. $price = $product_price_ron;
  41. $currency = 'RON';
  42. } else if ($the_coin == 'dollar') {
  43. $price = $product_price_dollar;
  44. $currency = '$';
  45. } else if ($the_coin == 'euro') {
  46. $price = $product_price_euro;
  47. $currency = '€';
  48. }
  49. } else {
  50. $price = $product_price_ron;
  51. $currency = 'RON';
  52. }
  53. }
  54. $total_price = $price * $quantity;
  55.  
  56. $_SESSION['cart'][$product_id] = array('product_name' => $product_name, 'coin' => $currency, 'price' => $price, 'total_price' => $total_price, 'size' => $size, 'color' => $color, 'quantity' => $quantity);
  57.  
  58. $temp = $_SESSION['cart'];
  59. array_push($_SESSION['cart'][$product_id], $temp);
  60. //setcookie($the_product_id, $product_name.",".$currency.",".$price.",".$total_price.",".$size.",".$color.",".$quantity, time() + (86400 * 30), "/");
  61. header("Location: ".$_SERVER['HTTP_REFERER']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement