Getting product data (WooCommerce integration)
-
Hello,
I had a look into /integration/woocommerce.php and noticed that you get the product with the following piece of code:
$prodid = get_the_ID(); $product = get_product( $prodid );
Are there special reasons for not receiving the product this way:
global $product;
It will eliminate 2 functions calls. Does that make sense?
If $post is not set or has been modified and not reset yet and is not containing the correct ID, the following will cause a fatal error:
$product_price = $product->get_price();
By the way, that is the reason why I am writing this post. Perhaps, you need to add an early return if $product is not received for some reason. What do you think?
I would make a pull request on Github on this matter but the version there is outdated.
- The topic ‘Getting product data (WooCommerce integration)’ is closed to new replies.