I have a column of product links in my mySQL database and am trying to get the user to add multiple products in his/her cart and not redirect to the cart when adding a product each time. For some reason, my cart is not updating when the user clicks the link. Can anyone tell me what is wrong with my code? $producturl pulls the link from the database. I would like the link to trigger but stay on the page.
<?php $producturl = ProductURL::find(array('Product'=>$tube1->Tube1));
if($producturl[0]->URL!=NULL){
echo '<span id="shop">Add Cart NoRedirect</span>';
}
?>
<script type="text/javascript">
$(document).on('click', '#shop', function (event) {
$.post( '<?php echo $producturl[0]->URL; ?>' );
event.preventDefault();
event.stopPropagation();
alert('Product has been added to cart');
});
</script>