WordPress.org

Ready to get started?Download WordPress

Forums

[closed] WooCommerce - Display price in theme template. (3 posts)

  1. scdwb
    Member
    Posted 1 year ago #

    Hello,

    For the life of me I can't seem to display the simple product price in my theme. Most of the time I use this function:

    <?php echo $product->get_price_html(); ?>

    This seems to be the crème de la crème and everyone must be satisfied with this solution as I can't find anything on the net otherwise :-). However, the problem with this is that it echos both the sale price and the regular price within it's predefined HTML code layout.

    I want to be able to echo the sale price and regular price separately so I have more flexibility in designing themes.

    Looking into this function I see the following is used in the WC product variation class:

    woocommerce_price( $this->regular_price )

    and

    woocommerce_price( $this->sale_price)

    These sale_price and regular_price variables seem to be exactly want I want. But how do I display these within the theme?

    I've tried woocommerce_price( $product_id->regular_price ) with no luck.

    Can you please help or send over a link a any documentation which explain this?

    Many thanks,
    Steven

  2. vehicros
    Member
    Posted 1 year ago #

    HI, did you ever find a solution?

    I would also like the regular price to be Displayed, but I have a feeling it has something to do with Not all variations of a certain item being the same price, whether regular or sale.

    thanks
    -V-

  3. esmi
    Forum Moderator
    Posted 10 months ago #

    As per the Forum Welcome, please post your own topic. This topic is 9 months old!

Topic Closed

This topic has been closed to new replies.

About this Topic