Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get WooCommerce Product ID from It's Slug?

Is it possible to get an ID of a WooCommerce product only by knowing it's slug? I need to fetch the product's price outside the product's page.

like image 742
testimonial Avatar asked Sep 29 '17 10:09

testimonial


1 Answers

use the existing function get_page_by_path();

$product_obj = get_page_by_path( $slug, OBJECT, 'product' );

better explanation :

https://wordpress.stackexchange.com/questions/206886/get-product-details-by-url-key-in-wordpress-woocommerce

like image 143
newbie Avatar answered Oct 10 '22 22:10

newbie