• Resolved jazzu

    (@jazzu)


    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)
  • Hello there,

    Please check this article that explains how you can show Regular and sale price.

    Let us know if there are any questions.

    Thread Starter jazzu

    (@jazzu)

    Hi @ihereira !

    Thank you for your reply. I checked it out, I didn’t even think about the cart yet, so that’s one future-issue solved, so thank you ??

    But there’s still the problem for which I made the thread. You can check this link to see an example of a product that’s on sale.

    There are 3 variations. The first one is on sale (the left one) and the price is shown as if it’s the default price.

    Kind regards

    Hi @jazzu

    It looks like you are looking for help with the customization of the code. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out. For development oriented questions, I’d also recommend asking them on the following places:

    WooCommerce Slack Community: https://woocommerce.com/community-slack/
    WooCommerce Community on Facebook: https://www.facebook.com/groups/advanced.woocommerce/

    This thread has been inactive for a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

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.