This button has to change the product categories of this product.
Just to be sure in order to provide better assistance. May I ask the reason to change the product category? Can you provide an example, please?
In my shop, I have products with a calibration date so they have experation date and when the time comes those products change automatically in an other category, named “Expired”, but in order to calibrate them i need to put them in metrology. So I programmed a button in the product pages. This button appears only if products are in the category “Expired”. This button has to change category from “Expired” to “Metrology”.
We can change the product category in backend so I assume that there is a code or a function in order to change the category. Is it possible to apply this code to my button ?
Thanks for your answer
As I understand it, you want visitors to your website to be able to change the category of a product by clicking a button on the page displaying that product.
Products use a custom taxonomy for their categories. What you want to do can be done, but it is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.
I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.
You can also visit the WooCommerce Facebook group or the
#developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.