I have links for various products. I am using php to add the product ID from the database as the id value for each link.
<a class="order_btn" id="<?php echo $row['product_id'];?>"><?php echo $row['product_name']; ?></a>
I am using the jquery cookie plugin(https://github.com/carhartl/jquery-cookie) to save the number of times the order button is clicked. I am using the product ID from the id attribute as the key for the saved cookie.
$(".order_btn").click(function() {
var productToAdd = $(this).attr("id");
if($.cookie("Product-"+productToAdd) >= 1) { //If this is not the first item for the current product
//Updating the number for the current product
var newNum = Number($.cookie("Product-"+productToAdd)) + 1;
$.cookie("Product-"+productToAdd, newNum);
} else { //If this the first item for the current product
//Creating the first number for the current product
$.cookie("Product-"+productToAdd, 1);
}
}); //end click function for Order Button
On the Cart page, I need to list out the Product Name for each cookie that has saved values. Therefore, I need to be able to get the name of the key for the cookie so I can look up the products name in the database.
How can I get an array that has the keys for all current javascript cookies?