如果通过AJAX调用URL wc_clear_notices()
,如何调用PHP WooCommerce函数$product->add_to_cart_url()
?
PHP
<?php
echo '<div class="hs_cart vc_col-sm-2">' .
'<button url="' . $product->add_to_cart_url() . '">Add To Cart</button>' .
'</div>';
?>
JAVASCRIPT
<script>
$('.hs_cart button').click(function(){
$.get($(this).attr('url'));
});
</script>