Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AshlinRejo/99770c4dc5464f347d56e5f65df967a7 to your computer and use it in GitHub Desktop.
Save AshlinRejo/99770c4dc5464f347d56e5f65df967a7 to your computer and use it in GitHub Desktop.
Discount rules v2: Trigger quantity update on changing variant, update the varint price in main price html
add_filter('woocommerce_after_add_to_cart_form', function (){
?>
<script>
jQuery( document ).ready( function() {
jQuery( ".single_variation_wrap" ).on( "show_variation", function ( event, variation, purchasable ) {
jQuery(this).closest('form').find('input[name="quantity"]').trigger('change');
});
jQuery('input[name="quantity"]').trigger('change');
});
</script>
<?php
}, 10);
add_filter('advanced_woo_discount_rules_custom_target_for_variable_product_on_qty_update', function ($target){
$target = 'div.product .woocommerce-variation-price .price, div.product span.price';
return $target;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment