Woocommerce: Customizing the availability of a cat

2019-07-24 19:14发布

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:

  1. 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.
  2. 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.

1条回答
淡お忘
2楼-- · 2019-07-24 19:33

THE BEGINING

You can start adding 2 plugins to add a custom time picker on product categories admin pages:

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:

create a group

Then you set the location (It's going to be a "taxonomy term" for "Product categories"):

location

Then In options you can chose it like a Metabox on the side (on backend):

Metabox on side

After you add a new field and name it. You chose the field type and time only option:

Field type [Field type option[8]

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:

The custom field in action under product categories

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…

查看更多
登录 后发表回答