Last active
June 21, 2021 07:17
-
-
Save Balakrishnan-flycart/dbedc2afa7c54b50700f4e8e1361f241 to your computer and use it in GitHub Desktop.
Woo Discount Rules v2 - Dynamic strikeout on slae page
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_action( 'wp_footer', function () { | |
if(is_page( 'sale-products-copy' )){ | |
?> | |
<script> | |
jQuery(document).on('change', '[name="quantity"]', function (){ | |
var awdr_qty_object = jQuery(this); | |
setTimeout(function(){ | |
var $qty = awdr_qty_object.val(); | |
var $product_id = 0; | |
var $price_place = ""; | |
$product_id = awdr_qty_object.parent().siblings().attr("data-product_id"); | |
var target = awdr_qty_object.parents( '.woodmart-add-btn.wd-add-btn-replace').siblings('.price'); | |
$price_place = jQuery(target).first(); | |
var data = { | |
action: 'wdr_ajax', | |
method: 'get_price_html', | |
product_id: $product_id, | |
qty: $qty, | |
awdr_nonce: awdr_params.nonce, | |
}; | |
jQuery.ajax({ | |
url: awdr_params.ajaxurl, | |
data: data, | |
type: 'POST', | |
success: function (response) { | |
if (response.price_html) { | |
$price_place.html(response.price_html) | |
} else { | |
if(response.original_price_html != undefined){ | |
$price_place.html(response.original_price_html) | |
} | |
} | |
}, | |
error: function (response) { | |
$price_place.html("") | |
} | |
}); | |
}, 0); | |
}); | |
</script> | |
<?php } | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment