Dynamic strikeout on sale page
Implement a feature to dynamically strike through prices on the sale page.
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 }
} );