• Resolved Cultivate

    (@dpc036)


    Im trying to check if a product is a grouped product so that i can then get a list of the child products associated with it.

    Based on the documentation im using $product->get_type(); example code below.

    
    $product = new WC_Product( 90 );
    $type = $product->get_type();
    
    echo '<pre>';
    print_r($type);
    echo '</pre>';
    

    However this displays a type of simple, despite the product with ID 90 being a grouped product. Is this a bug or am i doing something wrong?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Cultivate

    (@dpc036)

    A little update on this.

    When a product is viewed on a single product page the product correctly displays as a grouped product.

    However im trying to display a link to purchase a specific product on a page. That is when the type is displayed as simple when using the above code.

    Plugin Support John Coy a11n

    (@johndcoy)

    Automattic Happiness Engineer

    Hi @dpc036

    The default Grouped product view has a list of product that customers can pick from and I am not sure how different it is than what you’re trying to achieve:

    https://woocommerce.com/videos/woocommerce-grouped-product-overview/

    Plugin Support Steve E.a11n

    (@woosteve)

    Automattic Happiness Engineer

    Hi there,

    There are no recent responses to this thread so I’ll mark this as resolved. Please feel free to open a new thread if you have any further questions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Check if a product is grouped with get_type() not working’ is closed to new replies.