Add Product Price in WooCommerce as a Shortcode

Looking to insert a WooCommerce product price into a layout, well you can add the WooCommerce Product Price as a shortcode using the product ID as an attribute for the correct product.

The code below goes into your functions.php file, the add the shortcode where you need to display the price.

add_shortcode( 'cl_product_price', 'cl_woo_product_price_shortcode' );
 * Shortcode WooCommerce Product Price.
function cl_woo_product_price_shortcode( $atts ) {
	$atts = shortcode_atts( array(
		'id' => null
	), $atts, 'cl_product_price' );
	if ( empty( $atts[ 'id' ] ) ) {
		return '';
	$product = wc_get_product( $atts['id'] );
	if ( ! $product ) {
		return '';
	return $product->get_price_html();

And use the shortcode in the layout/template with the Product ID number as an attribute.

[cl_product_price id="1011"]


  1. Fabio on August 15, 2021 at 2:22 pm

    Can I apply a CSS style to this code?
    I tried:
    .woocommerce-Price-amount amount{
    color: #FF0000 !important;
    background: #FFFFFF !important;
    but it didn’t work. Your help would be much appreciated.


    • Neil Gowran on August 18, 2021 at 11:24 pm

      You missing a class prefix ‘.’ for ‘amount’ should be .amount

  2. hamedshh on August 3, 2021 at 5:27 pm

    is there any shotcode that without needing to add id being the price amount
    and is the a shortcode that bring the price amount and currency symbol separately
    I want to use two title boxes, one for price amount and one for price currency symbol

  3. Waleed on June 16, 2021 at 12:29 pm

    What about sale/original price? can I have those separate?

  4. Rene on December 13, 2020 at 5:53 pm

    i am asking for too much. can someone pls tell me which functions.php file do i need to update to use the shortcode…there are too many files and i am a not a developer. Thanks in advance!

    • Neil Gowran on December 15, 2020 at 11:12 pm

      It is the functions file that is in the active theme of the site.

  5. Clinton on August 6, 2020 at 4:52 pm

    The Code works Perfect, Thanks
    How to change the font size and color?

  6. Shaun Pan on June 29, 2020 at 1:37 am

    Great contribution work fine using product ID.
    –Dynamic price required instead of ID grab.
    But I am using in blocks lightbox pop up and I have twenty products with different prices, when user click link button the module show the same price for every product, I want see the module display the current product page price on popup blocks.
    Any help will be much appreciated.

  7. Stuart on June 5, 2020 at 10:23 am

    Is there a way to do this dynamically so instead of using an id it grabs it from the product page?

  8. V on May 18, 2020 at 11:00 am

    You already know that woocommerce has 2 prices, normal price and reduced price.
    Could it be that only the discounted price is displayed?

    Thank you!!

  9. V on May 18, 2020 at 10:42 am

    Worked perfectly!!!!

    I´m so happy =) =) =)

    Great thanks!!

  10. Sónia Dias on April 13, 2020 at 11:28 am

    Hi Lewis,

    I’ve tried using elementor but it doen’t work. :(

  11. lewis on March 7, 2020 at 12:31 am

    Worked Perfectly! Thank you for this code.

Leave all Comment