WooCommerce Product Add Ons, by WooCommerce - Do strikeout only for subtotal

WooCommerce Product Add Ons, by WooCommerce - Do strikeout only for subtotal

add_action( 'wp_head', function () {
    $currency_code = '$';
    if(function_exists('get_woocommerce_currency_symbol')){
        $currency_code = html_entity_decode(get_woocommerce_currency_symbol());
    }
    ?>
    <script type="application/javascript">
        (function ($) {
            $(document).ready(function ($) {
                var currency_string = '<?php echo $currency_code; ?>';
                var $form = jQuery('form.cart').first();
                /**
                 * Strikeout for option title product-addon
                 * */
                $('.wc-pao-subtotal-line .amount').each(function(){
                    var $targets = $(this);
                    $lock = $targets.attr('data-lock');
                    if($lock === undefined || $lock === null){
                        $lock = false;
                    }
                    if($lock == false){
                        var price = newText = $(this).text().replace(currency_string, '');
                        price = price.replace(',', '');
                        if(price!= '' && price != "-"){
                            var option = {
                                custom_price: price,
                                original_price: price
                            };
                            $targets.attr('data-lock', true);
                            $.AdvanceWooDiscountRules.getDynamicDiscountPriceFromCartForm($form, $targets, option);
                        }
                    }
                });

                $(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 = '';
                        var flat_discount_value = 0;
                        if(response.data !== undefined){
                            if(response.data.initial_price_html !== undefined && response.data.discounted_price_html !== undefined){
                                var has_flat = false;
                                for (const [key, details] of Object.entries(response.data.total_discount_details)) {
                                    var discount_details;
                                    if(details.set_discount != 0){
                                        discount_details = details.set_discount;
                                    } else if(details.bulk_discount != 0){
                                        discount_details = details.bulk_discount;
                                    } else if(details.simple_discount != 0){
                                        discount_details = details.simple_discount;
                                    }
                                    if(discount_details != 0){
                                        if(discount_details.discount_type!= undefined && discount_details.discount_type == "fixed_price"){
                                            has_flat = true;
                                            flat_discount_value += discount_details.discount_value*discount_details.discount_quantity;
                                        } else if(discount_details.discount_type!= undefined && discount_details.discount_type == "flat"){
                                            has_flat = true;
                                            flat_discount_value += ((response.data.initial_price/discount_details.discount_quantity) - discount_details.discount_value)*discount_details.discount_quantity;
                                        }
                                    }
                                }
                                if(has_flat == true){
                                    var discount_price = flat_discount_value;//response.data.initial_price-flat_discount_value;
                                    if(response.data.initial_price > discount_price){
                                        price_html += '<del>'+response.data.initial_price_html+'</del>';
                                        price_html += ' <ins>'+response.data.currency_symbol+(discount_price.toFixed(2))+'</ins>';
                                    } else {
                                        price_html += response.data.initial_price_html;
                                    }

                                } else {
                                    price_html += '<del>'+response.data.initial_price_html+'</del>';
                                    price_html += ' <ins>'+response.data.discounted_price_html+'</ins>';
                                }

                                target.html(price_html);
                            }
                        }
                    }
                    target.attr('data-lock', false);
                });

                /**
                 * Strikeout for option values and subtotal //product-addon-totals
                 * */
                $form.on('updated_addons', function () {
                    setTimeout(function () {
                        $('.wc-pao-subtotal-line .amount').each(function(){
                            var $targets = $(this);
                            $lock = $targets.attr('data-lock');
                            if($lock === undefined || $lock === null){
                                $lock = false;
                            }
                            if($lock == false){
                                var price = newText = $(this).text().replace(currency_string, '');
                                price = price.replace(',', '');
                                if(price!= '' && price != "-"){
                                    var option = {
                                        custom_price: price,
                                        original_price: price
                                    };
                                    $targets.attr('data-lock', true);
                                    $.AdvanceWooDiscountRules.getDynamicDiscountPriceFromCartForm($form, $targets, option);
                                }
                            }
                        });
                    }, 0);
                });
            });

        })(jQuery);
    </script>
<?php } );