Displaying the price and showing if a product is on sale
-
Hello!
I’m currently using a shortcode to display the price of a product. It works okay, but it doesn’t show that the product is on sale as it only shows the current price, so it’s not noticable. The code I’m using:
function so_30165014_price_shortcode_callback( $atts ) { $atts = shortcode_atts( array( 'id' => null, ), $atts, 'bartag' ); $html = ''; if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){ $_product = wc_get_product( $atts['id'] ); $html = wc_price( $_product->get_price() ); } return $html; } add_shortcode( 'price', 'so_30165014_price_shortcode_callback' );
This is how products on sale are displayed in main shop tab.
And THIS is what it looks like on the single product pages. I’d like the old price crossed and the new one displayed – just like it’s shown in the main shop tab.
Kind regards
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Displaying the price and showing if a product is on sale’ is closed to new replies.