Viewing 2 reply threads
  • Author
    Posts
    • #7412
      sebastianmerk
      Participant

      I use the example code of the piklist-demo to reference woocommerce products within my custom post type. For simple products this works right out of the box. But I can´t get my head around how to do this with product variations:

       array(
              'type' => 'select'
              ,'field' => '_' . piklist::$prefix . 'item_contracted'
              ,'label' => __('Contracted Item', 'myinventory')
              ,'columns' => 12
              ,'choices' => piklist(
                get_posts(array(
                  'post_type' => 'product'
                  ,'numberposts' => -1
                  ,'orderby' => 'title'
                  ,'order' => 'ASC'
                ))
                ,array('ID', 'post_title')
              )
              ,'relate' => array(
                'scope' => 'post'
              )
            ) 

      Would be great if someone could point me in the right direction.

      Thanks Sebastian

    • #7414
      Dan
      Participant

      Hi, this is on my list to look into. However as a starting point this hook may be of interest. It’s where I’m staring this evening – will let you know how I get on!!

      woocommerce_cli_save_product_variation
      https://docs.woocommerce.com/wc-apidocs/source-class-WC_CLI_Product.html#1781

    • #7415
      sebastianmerk
      Participant

      Sounds great. Will look into it as well. Keep me posted

Viewing 2 reply threads
  • You must be logged in to reply to this topic.