vendredi 27 février 2015

Cart not being updated after clicking link through JS


If anyone can provide assistance on my code that would be great. I am currently using WooCommerce and have put all the 'add-to-cart' links into a separate mySQL database. For example, this link: http://ift.tt/1DiVRaW adds a product to the cart.


I have created a web application with the separate mySQL database that the user can use to add products to the cart. My problem is that the cart does not get updated when he/she clicks the link.



<?php
$producturl = ProductURL::find(array('Product'=>$tube1->Tube1));
if($producturl[0]->URL!=NULL) {
echo '<span id="shop">Test2 Cart</span>';
}
?>

<script type="text/javascript">
$(document).on('click', '#shop', function (event) {
$.post( '" . $producturl[0]->URL . "' );
event.stopPropagation();
event.preventDefault();
alert('Product has been added to cart');
});
</script>


$producturl[0]->URL is the table that pulls my links. Is $.post not the right method for the server to recognize the user clicking the link? Help would be appreciated, thanks!





Aucun commentaire:

Enregistrer un commentaire