Dave111
Dave111

Reputation: 437

Woocommerce update payment methods based on shipping method

Im doing some changes on my eshop, I have moved shipping method and payment method choices from checkout page to cart page, but now those tables have lost their auto-update functionality, and this leads to getting order errors, based on "invalid payment method". I know I need to move some action, method or anything as well to the cart page, I just cant figure out what I need to move there.

Code I have moved from checkout to cart for displaying shipping methods

<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
    <?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
    <?php wc_cart_totals_shipping_html(); ?>
    <?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
<?php endif; ?>

functions.php action change

remove_action('woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20);
add_action('order-checkout-methods', 'woocommerce_checkout_payment', 20);

Code I have moved from checkout to cart for displaying payment methods

<?php do_action('order-checkout-methods'); ?>

Problem is not in the custom function. The auto-update worked well with this, but only when it was in checkout Any idea, what i need to add to the cart to make it work?

Upvotes: 0

Views: 523

Answers (1)

Arafat Rahman
Arafat Rahman

Reputation: 408

I see you have moved the display of shipping methods and payment methods from the checkout page to the cart page. but the issue is the auto-update functionality has been lost. that's why you need restore these.

To restore the auto-update functionality, you will need to move the relevant actions, methods, or code that handle the update of these fields to the cart page.

Upvotes: 1

Related Questions