Home Forums WoodMart support forum the Sale start date and Promotion end date below the price

the Sale start date and Promotion end date below the price

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #637302

    peteris.naglis
    Participant

    How to display the Sale start date and Promotion end date below the price in the Woodmart online store?

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

    Aizaz Imtiaz Awan
    Keymaster
    Xtemos team

    Hello,

    Navigate to Theme Settings > Single product > Show / hide elements > Enable the option Countdown timer. They will be added only to products with a sale price and the final date scheduled for that price.

    Please follow this guide:
    https://xtemos.com/docs-topic/product-sale-countdown/

    Best Regards.

    #637740

    peteris.naglis
    Participant

    Thank you! How can the counter be translated into other languages?

    #637869

    peteris.naglis
    Participant

    How can the counter be translated into other languages?

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

    Aizaz Imtiaz Awan
    Keymaster
    Xtemos team

    Hello,

    Try to translate those texts via the Loco Translate plugin, here is our article on how to use that – https://xtemos.com/docs-topic/translate-woodmart-theme-with-loco-translate/

    Best Regards,

    #637912

    peteris.naglis
    Participant

    How to display text with Sale start date and Promotion end date below the price in the woodmart theme online store? Without using Countdown timer

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

    Aizaz Imtiaz Awan
    Keymaster
    Xtemos team

    Hello,

    Unfortunately, displaying the Sale Start Date and Promotion End Date below the price is not possible using the built-in theme options. This requires custom code, which falls outside the theme support policy.

    However, I have searched and found this custom code that you can try:

    add_action('woocommerce_single_product_summary', function() {
        global $product;
        if ($product->is_on_sale()) {
            $sale_price_dates_from = get_post_meta($product->get_id(), '_sale_price_dates_from', true);
            $sale_price_dates_to = get_post_meta($product->get_id(), '_sale_price_dates_to', true);
    
            if ($sale_price_dates_from) {
                echo '<p class="sale-dates">Sale Starts: ' . date_i18n('F j, Y', $sale_price_dates_from) . '</p>';
            }
            if ($sale_price_dates_to) {
                echo '<p class="sale-dates">Promotion Ends: ' . date_i18n('F j, Y', $sale_price_dates_to) . '</p>';
            }
        }
    }, 25);

    Go to WordPress Dashboard > Appearance > Theme File Editor.
    Open your functions.php file (from your child theme).
    Copy and paste the above code at the bottom of the file.
    Click Update File and refresh your product page.

    If this code does not work on your site, we won’t be able to modify it further, as custom code adjustments are not included in the theme support policy.

    Best Regards,

    #638032

    peteris.naglis
    Participant

    Thanks! It’s solved! Here’s the PHP:
    function dateToLatvian($date) {
    $month = array(
    “january” => “janvārim”, “february” => “februārim”, “march” => “martam”, “april” => “aprīlim”, “may” => “maijam”, “june” => “jūnijam”,
    “july” => “jūlijam”, “august” => “augustam”, “september” => “septembrim”, “october” => “oktobrim”, “november” => “novembrim”, “december” => “decembrim”
    );
    $days = array(
    “monday” => “Pirmdiena”, “tuesday” => “Otrdiena”, “wednesday” => “Trešdiena”, “thursday” => “Ceturtdiena”,
    “friday” => “Piektdiena”, “saturday” => “Sestdiena”, “sunday” => “Svētdiena”
    );
    return str_replace(array_merge(array_keys($month), array_keys($days)), array_merge($month, $days), strtolower($date));
    }

    add_filter( ‘woocommerce_get_price_html’, ‘custom_price_html_lv’, 100, 2 );
    function custom_price_html_lv( $price, $product ){
    if ($product->is_type(‘variable’)) {
    $available_variations = $product->get_available_variations();
    $min_sale_price_date = null;

    foreach ($available_variations as $variation) {
    $variation_id = $variation[‘variation_id’];
    $sales_price_to = get_post_meta($variation_id, ‘_sale_price_dates_to’, true);
    if ($sales_price_to && (!$min_sale_price_date || $sales_price_to < $min_sale_price_date)) {
    $min_sale_price_date = $sales_price_to;
    }
    }
    } else {
    $min_sale_price_date = get_post_meta($product->get_id(), ‘_sale_price_dates_to’, true);
    }

    if ($min_sale_price_date) {
    $sales_price_date_to = dateToLatvian(date(“j. F”, $min_sale_price_date));
    $year = date(“Y”, $min_sale_price_date);
    return str_replace( ‘‘, ‘ <br><b style=”color:red;”>Atlaide spēkā līdz ‘.$year.’. gada ‘.$sales_price_date_to.’.</b>’, $price );
    } else {
    return apply_filters( ‘woocommerce_get_price’, $price );
    }
    }

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

    Aizaz Imtiaz Awan
    Keymaster
    Xtemos team

    Hello,

    Sounds Great! that your issue has been solved.

    You can always reach us at any time. We are always here to help you.

    Thanks for contacting us.
    Have a great day.

    Topic Closed.
    Best Regards.

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

The topic ‘the Sale start date and Promotion end date below the price’ is closed to new replies.