PHOENIX-MEDIA / Magento-PageCache-powered-by-Varnish

Community version which is available on Magento Connect (http://www.magentocommerce.com/magento-connect/pagecache-powered-by-varnish.html)
89 stars 49 forks source link

my shopping cart does not capture the products on the first attempt #64

Open BlackKwazi opened 4 years ago

BlackKwazi commented 4 years ago

if(isset($_POST["add_to_cart"])){

    if(isset($_SESSION["shopping_cart"])) {
        $item_array_id = array_column($_SESSION["shopping_cart"],"item_id");
        if(!in_array($_GET["ItemID"],$item_array_id)){

            $count = count($_SESSION["shopping_cart"]);
            $item_array = array(
                'item_id' => $_GET["ItemID"],
                'item_name' => $_POST["hidden_ProductName"],
                'item_price' => $_POST["hidden_ProductPrice"],
                'item_quantity' => $_POST["quantity"]
            );
            $_SESSION["shopping_cart"][$count] = $item_array;
        }
        else{
                echo '<script>alert("item already added, pick a different item")</script>';
                echo '<script> window.location ="productPage.php" </script>';
        }
    }
    else{
            $item_array = array(
                'item_id' => $_GET["ItemID"],
                'item_name' => $_POST["hidden_ProductName"],
                'item_price' => $_POST["hidden_ProdcutPrice"],
                'item_quantity' => $_POST["qunatity"]
            );
            $_SESSION["shopping_cart"][0] = $item_array;
    }
BlackKwazi commented 4 years ago

<?php if(!empty($_SESSION["shopping_cart"])){ $total = 0; foreach($_SESSION["shopping_cart"] as $keys => $values){ ?>

R R "> Remove
                    <?php 
                            $total = $total + ($values["item_quantity"] * $values["item_price"]);     
                        }
                    ?>
                    <tr>
                        <td colspan="3" align="right">Total</td>
                        <td align="rigt">R<?php echo number_format($total,2); ?> </td>
                        <td></td>
                    </tr>
                   <?php
                        }
                    ?>