Home Forums WoodMart support forum About the presentation of price

About the presentation of price

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #605282

    zhufan122881
    Participant

    Hello
    1、How can I make the original price font smaller than the discounted price?
    2、Is there a way to display how much money is saved in WooCommerce?
    Thank you!

    Attachments:
    You must be logged in to view attached files.
    #605481

    Hello,

    01. Can you please share the page URL so I can check and give you a possible solution?

    02. Try to add the following PHP code in the function.php of the child theme.

    add_filter( 'woocommerce_get_price_html',     'change_displayed_sale_price_html', 10, 2 );
    function change_displayed_sale_price_html( $price, $product ) {
         // Only on sale products on frontend and excluding min/max price on variable products
        if( $product->is_on_sale() && ! is_admin() && ! $product->is_type('variable')){
             // Get product prices
             $regular_price = (float) $product->get_regular_price(); // Regular price
             $sale_price = (float) $product->get_price(); // Active price (the "Sale price" when on-sale)
    
             // "Saving Percentage" calculation and formatting
             $precision = 1; // Max number of decimals
             $saving_percentage = round( 100 - ( $sale_price / $regular_price * 100 ), 1 ) . '%';
    
             // Append to the formated html price
             $price .= sprintf( __('<p class="saved-sale">You Save: %s</p>', 'woocommerce' ), $saving_percentage );
        }
        return $price;
    }

    Best Regards

    #605504

    zhufan122881
    Participant

    1、Actually this is another Theme, my friend told me. However, I did not use this theme because I think your theme is better, and it can be even more better.
    https://themeforest.net/item/motta-multivendor-and-marketplace-wordpress-theme/47722442

    #605527

    zhufan122881
    Participant

    2、I used this code. it works!
    But the numbers I want to show are monetary savings figures.
    Like : You Save: $99.00.
    And, this number is in red. I don’t know if it’s possible?
    Thank You!

    Attachments:
    You must be logged in to view attached files.
    #605568

    zhufan122881
    Participant

    2、In addition, I hope to adjust the font size of the regular price and not display the extra “you save” in the product archive.
    You can check my website for details.
    The account number and password are in the private message.
    Thank you

    #605751

    Hello,

    Remove the previous code and add the following PHP code in the function.php of the child theme.

    add_filter( 'woocommerce_get_price_html', 'change_displayed_sale_price_html', 10, 2 );
    function change_displayed_sale_price_html( $price, $product ) {
        // Only on sale products on frontend and excluding min/max price on variable products
        if( $product->is_on_sale() && ! is_admin() && ! $product->is_type('variable')) {
            // Get product prices
            $regular_price = (float) $product->get_regular_price(); // Regular price
            $sale_price = (float) $product->get_price(); // Active price (the "Sale price" when on-sale)
            
            // Calculate monetary savings
            $saving_amount = wc_price( $regular_price - $sale_price ); // Monetary saving
            
            // Append the savings in monetary form
            if ( is_product() ) { // Only show on single product page
                $price .= sprintf( __('<p class="saved-sale" style="color:red;">You Save: %s</p>', 'woocommerce' ), $saving_amount );
            }
        }
        return $price;
    }

    For the font adjustment, add the below Custom CSS code to Theme Settings > Custom CSS > Global Custom CSS.

    .woocommerce div.product p.price del { 
    font-size: 18px; /* Adjust the size here */
     }

    Best Regards

    #606647

    zhufan122881
    Participant

    Thank you for your reply.
    I used the above code with some adjustments and finally achieved the effect as shown in Figure 1.
    But a new problem emerged. The “you save” widget will appear elsewhere, which is not what I want. as shown in Figure 1、2.
    I think there should be one more restriction, but obviously the name “single product” is not precise enough.
    Because after I used this statement, the problem was not fixed.
    if( is_product() && $product->is_on_sale() && ! is_admin() && ! $product->is_type(‘variable’)) {
    How do I need to modify the code please?
    Thank you!

    • This reply was modified 4 weeks, 1 day ago by zhufan122881.
    • This reply was modified 4 weeks, 1 day ago by zhufan122881.
    Attachments:
    You must be logged in to view attached files.
    #606697

    Hello,

    Can you please share the page URL so I will check and give you a possible solution?

    Best Regards

    #606877

    zhufan122881
    Participant

    Sure
    wp-admin URL:https://365onsale.com/product/kidscleancar/

    #606954

    Hello,

    Sorry to say such modification requires complicated Woocommerce code customization which is not covered by our support.

    You need to find a third-party plugin to achieve more functionality that best suits you.

    Hope you can understand!

    Best Regards

Viewing 10 posts - 1 through 10 (of 10 total)