If you’re interested in customizing your WooCommerce checkout page with a persuasive message that encourages customers to take advantage of free shipping by placing their orders before a specified cutoff time, then this code snippet will assist you in achieving that.
// Display Free Shipping Before Certain Time in WooCommerce Checkout function ts_display_free_shipping_message() { // Set the cutoff time for free shipping (24-hour format) $cutoff_time = '22:00'; // Change this to your desired cutoff time // Get the current time $current_time = current_time('H:i'); // Check if the current time is before the cutoff time if (strtotime($current_time) < strtotime($cutoff_time)) { // Display the custom message echo '<p class="free-shipping-message">Order now and get free shipping before ' . $cutoff_time . '!</p>'; } } add_action('woocommerce_before_checkout_form', 'ts_display_free_shipping_message');
Output
The below output adds a message above the WooCommerce checkout form, notifying customers about the opportunity for free shipping if they place their order before a specified cutoff time.
Alternatively, you can also display custom messages for free shipping in WooCommerce cart page.