Display “You Save x%” below sale prices

This topic has 4 replies, 2 voices, and was last updated 3 years, 5 months ago ago by Olga Barlow

  • Avatar: FastFormations
    rj
    Participant
    November 8, 2020 at 10:14

    Hi

    I have added a function to show “You Save XX %” below sale price of the product.

    function ts_you_save() {
    
    global $product;
    
    if( $product->is_type('simple') || $product->is_type('external') || $product->is_type('grouped') ) {
    
    $regular_price = get_post_meta( $product->get_id(), '_regular_price', true );
    $sale_price = get_post_meta( $product->get_id(), '_sale_price', true );
    
    if( !empty($sale_price) ) {
    
    $amount_saved = $regular_price - $sale_price;
    $currency_symbol = get_woocommerce_currency_symbol();
    
    $percentage = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
    ?>
    <p style="font-size:16px;color:red;"><b>Extra <?php echo number_format($percentage,0, '', '').'% Off'; ?></b></p>
    <?php
    }
    }
    }
    
    add_action( 'woocommerce_single_product_summary', 'ts_you_save', 11 );

    But it shows only on single product page.

    https://prnt.sc/vfhi0b

    Can you please tell me how can I show it on product archive (shop) page on grid and list view also. I have used code snippets plugin to add the function.

    Also as you can see in the screenshot, the “add to cart” and “buy now” buttons have different width. Can you please give me a code to make width of 300 px for both buttons.

    Please, contact administrator
    for this information.
    3 Answers
    Avatar: FastFormations
    rj
    Participant
    November 8, 2020 at 11:42

    Hi

    All of sudden the products also disappeared from shop page and sliders.

    Its surely not because of using the code above

    it happened when I tried to bulk edit the products.

    Avatar: FastFormations
    rj
    Participant
    November 9, 2020 at 06:20

    Hi Products are showing again. But still need your assistance on my first message. Please also refer to my another topic

    https://www.8theme.com/topic/custom-grid-using-wpbakery-grid-builder-not-working/#post-258451

    As I guess all are somehow related so you can check in one go. I have provided access link in my first message.

    Thanks in advance.

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    November 9, 2020 at 14:57

    Hello,

    We have answered that topic. Use the same action to show your ts_you_save function for the shop grid.
    Besides additional customization is not included in our support https://themeforest.net/page/item_support_policy
    We could help you with minor CSS customization on an exceptional basis but if you need additional PHP customization then submit requests here.

    Regards

  • Viewing 4 results - 1 through 4 (of 4 total)

The issue related to '‘Display “You Save x%” below sale prices’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.