Home / Forums / WoodMart support forum / the Sale start date and Promotion end date below the price
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
- This topic has 8 replies, 2 voices, and was last updated 1 year, 5 months ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
February 11, 2025 at 10:02 pm #637302
peteris.naglisParticipantHow 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.February 12, 2025 at 12:24 pm #637453Hello,
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.
February 13, 2025 at 10:42 am #637740
peteris.naglisParticipantThank you! How can the counter be translated into other languages?
February 13, 2025 at 2:18 pm #637869
peteris.naglisParticipantHow can the counter be translated into other languages?
Attachments:
You must be logged in to view attached files.February 13, 2025 at 2:19 pm #637872Hello,
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,
February 13, 2025 at 4:23 pm #637912
peteris.naglisParticipantHow 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.February 14, 2025 at 8:53 am #638026Hello,
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,
February 14, 2025 at 10:05 am #638032
peteris.naglisParticipantThanks! 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.February 14, 2025 at 11:19 am #638063Hello,
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. -
AuthorPosts
The topic ‘the Sale start date and Promotion end date below the price’ is closed to new replies.
- You must be logged in to create new topics. Login / Register