WooCommerce get product prices

Today we talk about how WooCommerce get product price? In our example, we will get product price information like price, regular price, sale price, sale start date, and sale end date. So let’s start with our example.

If you want to load product information by it id then use the following code.

$p_id = 20;
$product_info = wc_get_product( $p_id );

Now you have product object. You can get price with the following code.

$product_info->get_price(); // get product price
$product_info->get_regular_price(); // get product regular price
$product_info->get_sale_price(); // get product sale price
$product_info->get_date_on_sale_from(); // get product sale from date
$product_info->get_date_on_sale_to(); // get product sale to date

Qaisar Satti

Hi, I'm Qaisar Satti! I've been a developer for over 20 years, and now I love sharing what I've learned through tutorials and guides. Whether you're working with Magento, PrestaShop, or WooCommerce, my goal is to make your development journey a bit easier and more fun. When I'm not coding or writing, you can find me exploring new tech trends and hanging out with the amazing developer community. Thanks for stopping by, and happy coding!