I have many products nested within parent categories in WooCommerce.
I want to be able to apply a custom field where I can specify a time availability for categories as a admin feature only in Back end.
Theory:
- Back end - On each parent category I will have this custom field where I can type or choose a
time frame
: for example 11:00-17:00
.
- Front end:
- During this
time frame
, users will be able to browse all the products within that category.
- Outside of this
time frame
all the products within that category will stay visible (but inactive) and they will be displayed greyed out or with a 'closed'
banner (something like that).
Can anybody help me with this or even suggest me where I can start?
Thanks in advance.
THE BEGINING
You can start adding 2 plugins to add a custom time picker on product categories admin pages:
- Advanced custom fields (ACF) plugin
- Date & Time Picker for Advanced Custom Fields or also Date and Time Picker Field
This is just he beginning (and I can't confirm that is the best way). So In ACF you create a group and you name it:
Then you set the location (It's going to be a "taxonomy term" for "Product categories"):
Then In options you can chose it like a Metabox on the side (on backend):
After you add a new field and name it. You chose the field type and time only option:
[
Then now you are going to compile all the other options to fit your needs. Then you can save and add, if you need a 2nd field…
Now if you go to the WooCommerce Products Menu, under categories submenu, you will get this:
Now you can read a little the ACF documentation and also the wooThemes/woocommerce dev. documentation too.
You can customize woocommerce overriding the templates and use hook filter and actions.
You will find in here on StackOverFlow and over internet a lot of code, examples and tutorials, to begin and try to achieve your project. When needed you will post questions to get helped, with the code you are using telling what is working and what not…