<a id=”buyp” href=”#”>Buy product!</a>
<script>
$(‘#buyp’).click(function(e) {
e.preventDefault();
addToCart(199);
return false;
});

function addToCart(pid) {
$.get(‘/wp/?post_type=product&add-to-cart=’ + pid, function() {
// call back
});
}

Please login or Register to submit your answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.