0

I am working with WooCommerce version 3.2.5 and I would like to display product id on each single product view.

I was reading some stackoverflow posts that I should add:

global $product;
$id = $product->id;

into functions.php and then make call to my variable with something like this:

"' . get_the_ID() . '"

But this doesn't work for me. I am getting error when i try to update functions.php.

So my goal is to read product ID and put it inside shortcode:

[add_to_cart id="99"]

with this I would be able to display add to cart in any place of single product.

Thank you for help.

Aljaz
  • 303
  • 4
  • 18
  • This have your answer [link](https://docs.woocommerce.com/document/woocommerce-shortcodes/) – daultimate Jan 30 '18 at 13:47
  • But I want to load ID dynamically, not to actually put the id of product in each time or did I miss something here ? – Aljaz Jan 30 '18 at 14:49

0 Answers0