Compatible for WooCommerce Product Add-Ons Ultimate By Plugin Republic

Ensure compatibility with the WooCommerce Product Add-Ons Ultimate plugin by Plugin Republic.

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
});