Last active
July 21, 2021 05:35
-
-
Save Balakrishnan-flycart/437257825172f83fcd4e50b84d8cee7b to your computer and use it in GitHub Desktop.
Woo Discount Rules v2 - Compatible for WooCommerce Product Add-Ons Ultimate By Plugin Republic
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 () {?> | |
<script type="application/javascript"> | |
function compatiblePriceStrikeOut() { | |
var $form = jQuery('form.cart').first(); | |
var $targets = jQuery('.pewc-total-field'); //Target div selector for change product price. You can get this target on response event advanced_woo_discount_rules_on_get_response_for_dynamic_discount | |
var option = { | |
custom_price: jQuery('#pewc_total_calc_price').val(), //get current product price | |
original_price:jQuery('#pewc_total_calc_price').val() | |
}; | |
jQuery.AdvanceWooDiscountRules.getDynamicDiscountPriceFromCartForm($form, $targets, option); | |
jQuery(document.body).on("advanced_woo_discount_rules_on_get_response_for_dynamic_discount", function (e, response, target, options) { | |
if (response.success == true) { | |
var price_html = '' | |
if (response.data !== undefined) { | |
if (response.data.initial_price_html !== undefined && response.data.discounted_price_html !== undefined) { | |
price_html += '<del>' + response.data.initial_price_html + '</del>'; | |
price_html += ' <ins>' + response.data.discounted_price_html + '</ins>'; | |
jQuery('.pewc-total-field').html(price_html); | |
jQuery('.dd-selected-description.dd-desc.dd-selected-description-truncated').html(price_html); | |
} | |
} | |
} | |
}); | |
} | |
jQuery(document).ready(function () { | |
compatiblePriceStrikeOut(); | |
}); | |
jQuery(document).on('input change', function () { | |
setTimeout(function(){ compatiblePriceStrikeOut(); }, 1000); | |
}); | |
</script><?php | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment