Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Created March 8, 2013 04:14
Show Gist options
  • Save claudiosanches/5114173 to your computer and use it in GitHub Desktop.
Save claudiosanches/5114173 to your computer and use it in GitHub Desktop.
Ajax cart.
<?php
function cs_wc_loop_add_to_cart_scripts() {
if ( is_shop() || is_product_category() || is_product_tag() || is_product() ) : ?>
<script>
jQuery(document).ready(function($) {
$(document).on( 'change', '.quantity .qty', function() {
$(this).parent('.quantity').next('.add_to_cart_button').attr('data-quantity', $(this).val());
});
});
</script>
<?php endif;
}
add_action( 'wp_head', 'cs_wc_loop_add_to_cart_scripts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment