'; if (isset($product['full_path'])) { $meta .= ''; } //GET RELATED MEDIA $product_media = ioAPIv2('/v2/products_media/product_id='.$product['rowID'],'',$clientsecret); $product_media = json_decode($product_media,true); // If the user clicked the add to cart button if (isset($_POST['product'])) { //VALIDATE THE INPUT FOR THE SHOPPING CART $payload = json_encode($_POST['product'], JSON_UNESCAPED_UNICODE); $product_to_cart = ioAPIv2('/v2/shopping_cart/',$payload,$clientsecret); $product_to_cart = json_decode($product_to_cart,true); // Check if the product exists (array is not empty) if ($product_to_cart['quantity'] > 0) { // Product exists in database, now we can create/update the session variable for the cart if (!isset($_SESSION['cart'])) { // Shopping cart session variable doesnt exist, create it $_SESSION['cart'] = []; } $cart_product = &get_cart_product($product_to_cart['id'], $product_to_cart['options']); if ($cart_product) { // Product exists in cart, update the quanity $cart_product['quantity'] += $quantity; } else { // Product is not in cart, add it $_SESSION['cart'][] = $product_to_cart; } } // Prevent form resubmission... header('Location: ' . url('index.php?page=cart')); exit; } } else { // Output simple error if the id wasn't specified http_response_code(404); exit('Product does not exist!'); } //LINK to products page: $products_link = url(link_to_collection); $product_link = url('index.php?page=product&id='.($product['url_slug'] ? $product['url_slug'] : $product['rowID'])); /*Notifier - when 1 user ask for product notification $notifier = 0; if (isset($_POST["notifier"])){ $stmt = $pdo->prepare('SELECT * FROM accounts WHERE id = ?'); $stmt->execute([ $_SESSION['account_id'] ]); $account = $stmt->fetch(PDO::FETCH_ASSOC); $email = $account['email']; send_product_notification_email($email, $_POST["product_details"]); $notifier = 1; } */ $view = template_header((${$product['productname']} ?? $product['productname']), $meta); if ($error){ $view .='
'.$error.'
'; } else { $view .='/ '.(${$product['productname']} ?? $product['productname']).'
/ '.(${$product['productname']} ?? $product['productname']).'
'.$stock_status.'
'; $view .='