2017 Update – since WooCommerce 3:
global $product;
$id = $product->get_id();
Woocommerce doesn’t like you accessing those variables directly. This will get rid of any warnings from woocommerce if your wp_debug is true.
More Related Contents:
- Display in stock data in short description [closed]
- Get Order items and WC_Order_Item_Product in WooCommerce 3
- Change cart item prices in Woocommerce 3
- Replace the Variable Price range by the chosen variation price in WooCommerce 3
- Create programmatically a WooCommerce product variation with new attribute values
- Change product prices via a hook in WooCommerce 3+
- Checking if customer has already bought something in WooCommerce
- Check if a user/guest has purchased specific products in WooCommerce
- Get in WooCommerce cart the product ID of a cart item
- WooCommerce: Check if items are already in cart
- Updating product stock programmatically in Woocommerce 3
- Hide variation info from cart item title in WooCommerce 3+
- Disable add to cart button for an array of products IDs in WooCommerce
- Get all Orders IDs from a product ID in Woocommerce
- Get custom product attributes in Woocommerce
- Set product sale price programmatically in WooCommerce 3
- Create new product attribute programmatically in Woocommerce
- Adding multiple tabs to WooCommerce single product pages
- Replace add to cart button with a read more linked to product page on shop pages in WooCommerce 3
- Add a line break in Woocommerce Product Titles
- Create programmatically a product using CRUD methods in Woocommerce 3
- Allow re-sending New Order Notification in WooCommerce 5+
- WooCommerce: Add product to cart with price override?
- Create programmatically a variable product and two new attributes in WooCommerce
- How can I get customer details from an order in WooCommerce?
- WooCommerce : Add custom Metabox to admin order page
- Programmatically creating new order in Woocommerce
- Get coupon data from WooCommerce orders
- Show stock status next to each attribute value in WooCommerce variable products
- Add a custom column with meta data to My Account Orders table in Woocommerce 3+