I am trying to:
I am overriding the WooCommerce Cart page.
I have a new Custom Post called "Style". A Style has a 1:N relationship with a Product. (One style will have 5-10 products. A product belongs to only one Style).
In the WooCommerce page I need to get the Style for the Product. The SLUG for the relationship is: style-product
Here's my code:
echo "<h1>PRODUCT ID IS " . $product_id . "</h1>";
$style_id = toolset_get_related_post( get_post($product_id), array( 'style-product', 'parent' ) );
echo "<h1>STYLE ID IS " . $style_id . "</h1>";
Link to a page where the issue can be seen:
hidden link
I expected to see:
The style for the product.
Instead, I got:
A zero for post id.
I also tried this:
$style_id = toolset_get_related_post( get_post($product_id), array( 'style', 'style-product' ) );
It did not work.
I can't find any documentation that shows how to get relationships for WooCommerce products.
$style_id = toolset_get_related_post( get_post($product_id), 'style-product' );