Smart Coupons provide a powerful, “all-in-one” solution for gift cards, store credits, discount coupons, and vouchers extending the core functionality of WooCommerce coupons.
This doc article explains how to change the coupon expiry date format on your WooCommerce store.
Currently, Smart Coupons uses the date format of the website that is set under the menu Settings > General > Date Format as the display format of the expiry date.
In this guide, we’ll change the display format of the expiry date to the format other than the date format of the website that is set under the menu Settings > General > Date Format.
Steps to change display format of expiry date
↑ Back to top- Open the directory of the child theme of your website.
- Find a file named
functions.php
. - Open the file in an editor.
- Copy & paste the following code at the end of
functions.php
file.
/** * Change the display format of the expiry date of the coupon which is displayed on the website & set it as per the website's setting * * @author StoreApps.org */ function storeapps_wc_sc_formatted_coupon_expiry_date( $expires_string = '', $args = array() ) { $expiry_date = ( ! empty( $args['expiry_date'] ) ) ? $args['expiry_date'] : 0; if ( $expiry_date instanceof WC_DateTime ) { $expiry_date = $expiry_date->getTimestamp(); } elseif ( ! is_int( $expiry_date ) ) { $expiry_date = strtotime( $expiry_date ); } if ( ! empty( $expiry_date ) ) { $expires_string = date_i18n( 'd-M-Y', $expiry_date ); } return $expires_string; } add_filter( 'wc_sc_formatted_coupon_expiry_date', 'storeapps_wc_sc_formatted_coupon_expiry_date', 99, 2 );
- Save the file.
That’s it.