These PHP code snippets enable you to restrict the sales of products to 1 specific category on a specific day. Example : If you only want flowers from 1 specific category to be sold on valentines day, you can set the date on the code and the category so only flowers from that one category can be sold on a specific date.
This removes the add to cart button from all products in all other categories so only items in a specific category include a button allowing the product to be added to the cart.
Parent & Child Categories
The 1st code snippet applies to parent categories only and the 2nd to all category levels.
Copy & paste 1 of the 2 code snippets to the end of your child themes functions file or custom functionality plugin.
Swap out the allowed-category slug with the category slug for your specific category.
Swap out the date as well so the code only runs on a specific date.
You may also like…
These solutions may also help :