Customising the Plugin
To you these snippets, make sure you’re using a custom child theme, then paste them into functions.php.
Custom Styles
Include a custom mini-stylesheet on single product pages that use the date chooser.
function custom_delivery_dates_enqueue_scripts() {
$base_uri = get_stylesheet_directory_uri();
$theme_version = wp_get_theme()->get('Version');
if (function_exists('cpdd_are_custom_delivery_assets_required') && cpdd_are_custom_delivery_assets_required()) {
wp_enqueue_style(
'child-cpdd',
get_stylesheet_directory_uri() . '/custom-delivery.css',
null,
$theme_version
);
}
}
add_action('wp_enqueue_scripts', 'custom_delivery_dates_enqueue_scripts');
…and add your custom styles into “custom-delivery.css”.
Dynamically Prevent Delivery Dates
This snippet will prevent Mondays from being available for deliveries.
/**
* Given an input date (yyyy-mm-dd), return whether or not that date is
* blocked-out of the delivery date picker as unavailable.
*/
function custom_cpdd_is_delivery_date_blocked($is_blocked, $date_string) {
$date = new DateTime($date_string, wp_timezone());
// PHP DateTime formatting:
// https://www.php.net/manual/en/datetime.format.php
$day_of_week = intval($date->format('N'));
// Block Mondays
if ($day_of_week == 1) {
$is_blocked = true;
}
// More custom date-blocking conditions...
// ...
// ...
return $is_blocked;
}
add_filter('cpdd_is_delivery_date_blocked', 'custom_cpdd_is_delivery_date_blocked', 10, 2);
Changelog: Custom Product Delivery Dates
Version 1.1.2
Released: 2022-10-07
- Replaced deprecated WooCommerce action hook with the newer woocommerce_checkout_create_order_line_item. There should be no functional difference in general use of the plugin.
Version 1.1.1
Released: 2022-10-07
- Added a new option to copy cart item delivery method/date to the order item meta. Useful when you want to export product data from your WooCommerce orders.
Version 1.1.0
Released: 2022-09-29
Added a new option to the WooCommerce product editor, to make specific days of the week available/unavailable for delivery (at product-level).
Older releases
Minor update to support the newer version of the Power Plugins back-end updater.
- Fixed problem with the date picker not rendering on simple products.
- Fixed a typo in the admin area.
- Updated JS to fix a problem after changing product variation.
Reviews
There are no reviews yet.