Home Forums WoodMart support forum Promotion with a discount label displayed

Promotion with a discount label displayed

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #646242

    kruajeng
    Participant

    I want to set up a product promotion with a discount label displayed as shown in this image.

    How do I do that?

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

    Hello,

    There is no option in the theme settings to display the save price like this. This requires customization, which is beyond our support policy.

    I have searched for a possible solution and found a custom function that you can add to your functions.php file. If the provided code does not work as expected, unfortunately, we are unable to modify it further.

    Add this to your theme’s functions.php file of the theme.

    add_filter('woocommerce_get_price_html', 'custom_sale_savings', 10, 2);
    function custom_sale_savings($price, $product) {
        if ($product->is_on_sale()) {
            $regular_price = $product->get_regular_price();
            $sale_price = $product->get_sale_price();
            $savings = $regular_price - $sale_price;
            $price .= '<span class="save-price">Save $' . number_format($savings, 2) . '</span>';
        }
        return $price;
    }

    To style the save price add the following code in Theme Settings > Custom CSS > Global CSS area.

    .save-price {
        display: inline-block;
        background-color: #ff0000; /* Change to your preferred color */
        color: #fff;
        font-size: 14px;
        font-weight: bold;
        padding: 3px 8px;
        border-radius: 5px;
        margin-left: 10px;
    }

    Hope this Helps!

    Best Regards,

    #646451

    kruajeng
    Participant

    Hello, Aizaz Imtiaz Awan
    Could you please tell me
    How to remove or change the currency To ฿?
    I sell products in Thailand.

    And I can’t find the functions.php file.
    Which menu in the theme is it hidden under? Could you please check?

    Thank you.

    #646511

    Hello,

    01. You can modify the currency symbol in the code by replacing “$” with “฿” like this:

    add_filter('woocommerce_get_price_html', 'custom_sale_savings', 10, 2);
    function custom_sale_savings($price, $product) {
        if ($product->is_on_sale()) {
            $regular_price = $product->get_regular_price();
            $sale_price = $product->get_sale_price();
            $savings = $regular_price - $sale_price;
            $price .= '<span class="save-price">Save ฿' . number_format($savings, 2) . '</span>';
        }
        return $price;
    }

    02. You can use a file manager plugin to edit your wp-config.php file.

    Install and activate a https://wordpress.org/plugins/wp-file-manager/

    Open the file manager plugin in your WordPress dashboard. Navigate to your website’s root directory and locate the wp-config.php file.

    Use the plugin’s code editor to open the file. Search for define(‘DISALLOW_FILE_EDIT’, true); and change true to false.

    Follow this guide: https://theplusaddons.com/blog/how-to-fix-wordpress-theme-file-editor-missing

    Best Regards,

    #646518

    kruajeng
    Participant

    Hello, Aizaz Imtiaz Awan

    I enabled Auto height for all,
    But the heights are still inconsistent.

    How can I correct this?

    Attachments:
    You must be logged in to view attached files.
Viewing 5 posts - 1 through 5 (of 5 total)