Last active
November 22, 2021 07:25
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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