Remove Payment Gateways for Orders Until Set Count is Reached


This code enables you to restrict payment for a product until a specific level of orders have been submitted. If less than the set amount has been ordered, the available gateways and payment options are removed enabling ordering without payment by C.O.D only until the order limit is reached.

  • The code calculates the order count by number of individual orders not quantity.
  • The code enables you to change the payment gateway title and description.
  • The code also enables you to unset/remove different payment gateways conditionally. In this case based on order count and product I.D

Note : The code includes payment gateway I.D’s to remove WooCommerce Payments ( WooPayments ), WooCommerce PayPal Payments, WooCommerce Stripe Gateway, Cheque and Bank Transfer payment options only leaving the C.O.D option for taking orders when the count is below your set threshold.


There’s 3 steps :

Step 1 – Install the zip folder as a new plugin or copy and paste the PHP code from the plugin.php file to the end of your child themes functions.php file or custom functionality plugin.

Step 2 – Swap out all instances of 10 with the number you want to limit before payment is enabled for your product.

Step 3 – Swap out the product I.D in the PHP code from 15130 to match your product I.D.

These solutions may also help :