woocommerce variations

后端 未结 5 856
再見小時候
再見小時候 2020-12-14 08:14

I am creating a woocommerce theme and I have product variations i.e. size which is displayed on product details page but problem is that I want to get all variations in my c

5条回答
  •  情歌与酒
    2020-12-14 08:46

    You can use the code below:

    global $woocommerce, $product, $post;
    // test if product is variable
    if ($product->is_type( 'variable' )) 
    {
        $available_variations = $product->get_available_variations();
        foreach ($available_variations as $key => $value) 
        { 
            //get values HERE  
        }
    }
    

提交回复
热议问题