So here how it goes, I tried to simplify my checkout by adding the form code from the checkout template on at the side of my content-single-product.php template, but the thing is whenever I add a product to my cart, the total is not adding up so the payment methods are not showing.

What I notice is that whenever i go to the /cart page of my site, there is a Ajax loading on the checkout form to calculate the total, after the loading when I check my single product page again, the payment methods are now visible.

Is there a way I can update the total price whenever I add a product to my cart so that I can checkout immediately in my single product page?

here is the code that i included in the single product page:

<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
        <h3 id="order_review_heading"><?php _e( 'Your order', 'woocommerce' ); ?></h3>
        <?php do_action( 'woocommerce_checkout_before_order_review' ); ?>
        <div id="order_review" class="woocommerce-checkout-review-order">
            <?php do_action( 'woocommerce_checkout_order_review' ); ?>
        </div>
        <?php do_action( 'woocommerce_checkout_after_order_review' ); ?>
</form>

Read more here: Woocommerce – Ajax refresh after add to cart on my Check out form in my content-single-product.php template


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: