Skip to content
Advertisement

Disable specific payment methods depending on Woocommerce order status

I made a two-step payment on the site. Payment occurs after confirmation of the order by the manager. First, the user selects the payment method “for confirmation”(renamed “cash on delivery”) and pay only after receiving the invoice for payment. On the checkout page, I hide paypal via js. I would like paypal to be hidden when on-hold status. When the status of “Pending payment” is disabled “for confirmation”(renamed “cash on delivery”) and payment via paypal is available.

Advertisement

Answer

Update July 2020

The following code will show hide payment gateways:

  1. On checkout page it will remove “paypal” payment option (So you can remove your jQuery code)
  2. On Order Pay page it will:
  • Keep “paypal” only payment option if the order status is “pending” (removing all other options)
  • For others order statuses than “pending”, the payment is not allowed by Woocommerce

The code:

JavaScript

Code goes in function.php file of your active child theme (or active theme). Tested and work.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement