Adding delivery days in WooCommerce is a great way to keep your customers updated on when they can expect their orders. By default, WooCommerce only displays the date that an order was placed on the order detail page.
However, you can add delivery days to WooCommerce by installing a plugin or by adding code to your site.
Installing a Plugin
There are a few plugins that will add delivery days to WooCommerce. One of the most popular is the WooCommerce Delivery Date plugin. This plugin is free and easy to install.
Once you install and activate the plugin, you will need to configure it. You can do this by going to WooCommerce > Settings > Delivery Date. From here, you can choose which days of the week orders will be delivered, what time orders need to be placed by for same-day delivery, and how many days in advance customers can place orders.
Adding Code
If you don’t want to install a plugin, you can also add code to your site to add delivery days in WooCommerce. First, you will need to edit your functions.php file.
You can do this by going to Appearance > Editor. Once you are in the editor, select the functions.php file from the right hand sidebar. Then, copy and paste the following code into the file:
function wc_add_delivery_days() {
global $woocommerce;
$delivery_days = array(
'sunday' => __( 'Sunday', 'woocommerce' ),
'monday' => __( 'Monday', 'woocommerce' ),
'tuesday' => __( 'Tuesday', 'woocommerce' ),
'wednesday' => __( 'Wednesday', 'woocommerce' ),
'thursday' => __( 'Thursday', 'woocommerce' ),
'friday' => __( 'Friday', 'woocommerce' ),
'saturday' => __( 'Saturday', 'woocommerce' )
);
$current_delivery_day = isset( $woocommerce->session->chosen_delivery_day ) ? $woocommerce->session->chosen_delivery_day : ''; ?>
<form class="cart" action="<?php echo esc_url( home_url() ); ?>" method="post">
<select name="chosen_delivery_day" id="chosen_delivery_day" class="select" style="width:100%;">
<option value=""><?php _e('Select a delivery day..', 'woocommerce'); ?></option>
<?php foreach ( $delivery_days as $key => $value ) : ?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $current_delivery_day, $key ); ?>><?php echo esc_html( $value ); ?></option>
<?php endforeach; ?>
</select>
<input type="submit" class="button" value="Update" />
</form>
}
add_action('wp_footer', 'wc_add_delivery_days');
function wc_save_delivery_days() {
global $woocommerce;
if ( isset($_POST['chosen_delivery_day'])) {
$woocommerce->session->chosen_delivery_day = sanitize_text_field($_POST['chosen_delivery_day']);
}
}
add_action('wp_footer', 'wc_save_delivery_days');
First and foremost, please be aware that adding delivery days can potentially increase the cost of shipping for your customers. Additionally, please be sure to test your shipping setup thoroughly before making any changes live on your site, as there could be unforeseen issues that arise.
Finally, please keep in mind that adding delivery days may impact your customer satisfaction levels, so be sure to monitor feedback closely after making any changes.
Conclusion:
In conclusion, adding delivery days in WooCommerce is a great way to keep your customers updated on when they expect their orders. You can add delivery days in WooCommerce either by installing a plugin or by adding code to your site.