Support » Plugin: WooCommerce » [2.7] How to change product type when new product is added

  • Now sure whether this forum is the best place for my query, but didn’t know elsewhere better to ask support.

    This issue is about WC2.7 beta that I currently testing.

    When a new product is added in the admin backend – and while is still stored as Auto Draft – I want to programmatically:

    1. change product type to variable
    2. add an existing attribute and terms
    3. create variations using the attribute terms

    Any one knows how to achieve this? I’m just looking for a strawman, high level direction, not a full solution.

    Since WC2.5+ I have been hooking into save_post action and using roughly update_post_meta to add the attribute, wp_insert_post to create the variations and javascript to set the product type selector to Variable Product. With 2.7 this will not work.

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Plugin Support RK

    (@riaanknoetze)

    I’d recommend using the REST API instead for that; 2.7 has updated all the CRUD functions required for that 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘[2.7] How to change product type when new product is added’ is closed to new replies.