This PHP code enables you to set a minimum order amount so buyers can only complete the checkout process if the minimum total is equaled or exceeded unless they purchase a product which contains a specific word. If they do, they are exempt from the minimum order and can complete the checkout process.
In this example, the word is ‘PDF’ meaning any product title/name or variation name/description which contains the word PDF ( in upper or lower cases ), is exempt from the minimum order amount which in this case is set at $50.
The code checks the cart items subtotal to see if it meets the minimum amount and displays a message like this :
In the above case, the order cannot proceed to checkout as an error is displayed if the buyer tries to and is redirected back to the cart page as seen in the demo video.
If the cart contains a product with the word PDF or pdf, the minimum order amount is waived and the error notice is NOT displayed allowing the customer to complete the checkout process, as seen in the demo video.
Note : Works with single products and product variations using the variation name and/or variation description.
PHP Code Installation
- Copy & paste the PHP code to the end of your child themes functions file or custom code snippets plugin.
-
Set the minimum order amount on line 21 and a comma separated string of words on line 27. In this case, to check for lower and uppercase.
Note : If you want to use the code to check for specific words in variation names and variation descriptions, use the code from functions-2.php.
Reviews
There are no reviews yet.