jQuery(document).ready(function(){
    jQuery('form.checkout').on('change', 'input[name="payment_method"]', function(){
        jQuery(document.body).trigger('update_checkout');
    });

    /* jQuery(document).on('keyup mouseup change', '#customer_instalment', function() {
        let cartCurrency = jQuery('.payment_method_paythen .cart-total').attr("data-currency");
        jQuery('.shop_table').find('.order-total .woocommerce-Price-amount').each(function(){
            updatedCartTotal = jQuery(this).text();
        });
        updatedCartTotal = updatedCartTotal.replace(cartCurrency,'');
        updatedCartTotal = updatedCartTotal.replace(/,/g, '');
        jQuery('.payment_method_paythen .cart-total').attr('data-total', updatedCartTotal);

        let cartTotal = jQuery('.payment_method_paythen .cart-total').attr("data-total");
        let customerInstalment =  jQuery(this).val();
        let totalAmount = Math.round(cartTotal / customerInstalment);
        if (customerInstalment === ''){ jQuery('.payment_method_paythen .cart-total').html(''); jQuery('.refresh-cart-total').hide(); }
        else{ 
            jQuery('.payment_method_paythen .cart-total').html(`${customerInstalment} payments of ${cartCurrency}${totalAmount} each`); 
            jQuery('.refresh-cart-total').show();
        }
    }); */

    jQuery('.paythen-modal').click(function(){
        jQuery('#paythen-product-detail').show(400);
    });
    jQuery('.product-detail-data span.close').click(function(){
        jQuery('#paythen-product-detail').hide(400);
    });
});

