Woocommerce: Customizing the availability of a category

血红的双手。 提交于 2019-12-11 05:20:55

问题


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:


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…



来源:https://stackoverflow.com/questions/37974030/woocommerce-customizing-the-availability-of-a-category

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!