• Resolved rdxcsgoid

    (@rdxcsgoid)


    I was adding add to cart button.
    $product = new Wc_product(14) // 14 - product id
    $product->product_type returns null .
    I figured it out using wc_get_product(14) gives me the product type.
    But just curious why it returns null for Wc_product class.

    https://ww.wp.xz.cn/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    wc_get_product gets the correct product class which has type. Wc_product class used directly does not set this. Never do it directly.

    Thread Starter rdxcsgoid

    (@rdxcsgoid)

    Thanks Mike !

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘$product->product_type’ is closed to new replies.