Show hide payment methods based on selected shipping method in Woocommerce

The following code example will enable / disable payment gateways based on chosen shipping method. In this example, we have 3 shipping methods and 3 payment gateways. Each selected shipping method will enable only one different payment gateway. add_filter( ‘woocommerce_available_payment_gateways’, ‘payment_gateways_based_on_chosen_shipping_method’ ); function payment_gateways_based_on_chosen_shipping_method( $available_gateways ) { // Not in backend (admin) and Not in … Read more

Change COD default order status to “On Hold” instead of “Processing” in Woocommerce

Updated: The code that you found in Github is outdated, clumsy and complicated, since there is a dedicated filter hook now. You should better try this lightweight and effective code, that will set the default order status for “Cash on delivery” payment gateway (COD) to “On Hold”: add_filter( ‘woocommerce_cod_process_payment_order_status’, ‘change_cod_payment_order_status’, 10, 2 ); function change_cod_payment_order_status( … Read more

Add fee based on specific payment methods in WooCommerce

2021 UPDATE Note: All payment methods are only available on Checkout page. The following code will add conditionally a specific fee based on the chosen payment method: // Add a custom fee (fixed or based cart subtotal percentage) by payment add_action( ‘woocommerce_cart_calculate_fees’, ‘custom_handling_fee’ ); function custom_handling_fee ( $cart ) { if ( is_admin() && ! … Read more