I am sending the cart data of woocommerce to an externally hosted checkout page with the click of the 'proceed to checkout button. I just create inputs by looping the table and changing the cart form action URL to my external checkout page URL. My javascript function on button click stops after applying the coupon. If I reload the page, it starts working perfectly. Any suggestions on what could be blocking my js?
jQuery('a.checkout-button button alt wc-forward').click(function(e){
e.preventDefault();
jQuery('.cart_item').last().after('<input type="hidden" name="totalprice[]" value="'+jQuery('.order-total td').text()+'">');
jQuery('table.shop_table > tbody > tr').each(function(index, tr) {
if(jQuery(tr).hasClass('cart-discount'))
{jQuery('.cart_item td:last').after('<td class="coupon-val"><input type="hidden" name="coupon[]" value="'+jQuery(tr).find('th').text().replace(/Coupon:/g,"")+'" ></td>');
jQuery('.cart_item td:last').after('<td class="coupon-discount-val"><input type="hidden" name="coupon-discount[]" value="'+jQuery(tr).find('.woocommerce-Price-amount').text()+'" ></td>');
}
//jQuery(this).attr('href','http://localhost/test1/datapost.php');
});
//jQuery('form.woocommerce-cart-form').attr('action' , 'http://localhost/test1/datapost.php');
jQuery('form.woocommerce-cart-form').attr('action' , 'http://localhost/test1/datapost.php');
jQuery('form.woocommerce-cart-form').attr('id' , 'fsubmit');
jQuery('form.woocommerce-cart-form').removeAttr('class');
jQuery('body').find('#fsubmit').submit();
})****