I have a unique situation where we only allow 1 form of shipping and 1 form of payment for a particular brand of products. If this brand of products is in the cart, the customer can only pick up and can only pay via bank transfer.
When both of these are the only options and are selected by default, users tend to ignore it and place their orders, leading to more work due to needing to call the customer to follow up on the order.
Is there a way to make the only shipping and payment methods remain as radio buttons to be selected?
I’ve tried implementing the below code to not select one by default, but due to the shipping method not being a radio button, this doesn’t work, as well as the payment method code not working either.
add_filter( 'pre_option_woocommerce_default_gateway' . '__return_false', 99 );
add_filter( 'woocommerce_shipping_chosen_method', '__return_false', 99);
2
Answers
It looks like you’re trying to force the WooCommerce shipping payment method to be displayed as a radio button. This can be done using custom code or a plugin. However, if you’re also looking for a payment gateway solution that seamlessly integrates with WooCommerce and offers a high degree of customization, you might want to consider using MoneyCollect.
MoneyCollect provides a comprehensive payment gateway that can address your needs effectively.
To ensure that customers manually select the only available shipping and payment methods for a particular brand of products, you can use a combination of JavaScript and PHP. This will prevent the methods from being preselected and prompt the user to make a selection.
Step 1: Add JavaScript to Handle the UI Behavior
Add the following JavaScript to your theme’s functions.php file or a custom plugin to unselect the default options when the checkout page loads and ensure the user manually selects them before proceeding:
Step 2: Modify WooCommerce Filters
In addition to the JavaScript, use the following PHP filters to ensure WooCommerce does not preselect any shipping or payment methods on the server side:
This should help….