This thread is resolved. Here is a description of the problem and solution.
Problem: During checkout payment gateways are displayed even when the total amount is 0 (only free products in the cart). In this case the problem was due to a conflict with the WooCommerce Amazon Pay plugin.
Solution: We have identified a conflict between WooCommerce Multilingual (WCML) and the WooCommerce Amazon Pay plugin. As a temporary workaround, you can edit the WooCommerce Amazon Pay plugin code. Here are the steps:
We are using WooCommerce Multilingual & Multicurrency plugin for our multilingual shop. We have some free products and if a customer wants to order only free products the payment gateways are displayed. Which is not normal behaviour with a total amount of 0. They should be able to go straight to confirming the order without having to choose a payment gateway.
We deactivated several plugins and noted that the error doesn't occur with Woo Multilingual plugin deactivated. It worked until last week, and it all works fine with the plugin activated and products with a price. The problem arises only with free products.
We tried version 5.2.0 and 5.2.1, but no difference.
I can see the issue on your site, if I add a free product to the basket and go to the checkout.
I set up a test on my own local site and I can't reproduce the problem, I don't get the payment gateway section for free products, in either the original language or translated pages, so it looks like it may be related to something quite specific on your site.
Do you have a staging site available where I can perform some basic tests, including de-activating/re-activating plugins and switching settings?
Let me mark your next reply as private so that I can get log-in credentials for it from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site.
I ran some tests on your site, and I determined that the problem arises because of a conflict between WCML and the WooCommerce Amazon Pay plugin. Disable either plugin and the message is no longer displayed for free products.
I have escalated this to our Compatibility team so that they can investigate further, and I'll keep you posted with any feedback they have.
My colleague identified where the issue arises, in the code of the WooCommerce Amazon Pay plugin.
We can suggest an edit that you can make to their plugin to use as a workaround to fix the issue, which I share below.
Our compatibility team will try to contact the plugin authors about incorporating the solution, but it may also help if you contact them, and invite them to join the WPML Go Global programme, directing them to https://wpml.org/documentation/support/go-global-program/
The edit you can make is to the file wp-content/plugins/woocommerce-gateway-amazon-payments-advanced/includes/compats/class-wc-amazon-payments-advanced-woocommerce-multilingual-compat.php.
Around line 22 you will see the function maybe_restore_subtotal declared.
Replace the existing code for that function with this:
public function maybe_restore_subtotal( $cart ) {
if ( ! class_exists( 'woocommerce_wpml' ) ) {
return;
}
if ( ! defined( 'WC_DOING_AJAX' ) || ! WC_DOING_AJAX ) {
return;
}
if ( WC()->cart->total == 0) {
return;
}
// WCML sets cart->needs_payment() to become `false`.
add_filter( 'woocommerce_cart_needs_payment', '__return_true' );
}
That should resolve the problem for now. (If they update the plugin without making this change you may need to re-apply the above workaround.)