WooCommerce Product Add Ons, by WooCommerce - fix for price with comma separator

WooCommerce Product Add Ons, by WooCommerce - fix for price with comma separator

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 .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(",", '');
                        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 = ''
                        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>';
				target.html(price_html);
			    }
                        }
                    }
                    target.attr('data-lock', false);
                });

                /**
                 * Strikeout for option values and subtotal
                 * */
                $form.on('updated_addons', function () {
                    setTimeout(function () {
                        $('.product-addon-totals .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(",", '');
                                var option = {
                                    custom_price: price,
                                    original_price: price
                                };
                                $targets.attr('data-lock', true);
                                $.AdvanceWooDiscountRules.getDynamicDiscountPriceFromCartForm($form, $targets, option);
                            }
                        });
                    }, 0);
                });
            });

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