Search the site:

Home / Order Delivery Date Pro Hooks and Filters for Woocommerce

Order Delivery Date Pro Hooks and Filters for Woocommerce

WooCommerce Delivery Date Hooks:

Admin Settings:

Use the below hooks to perform actions on order delivery date setting in admin.

orddd_include_admin_scripts: Use this hook to add additional scripts along with the existing scripts used in the plugin.

Present in file: order-delivery-date.php

Usage:

<?php
add_action('orddd_include_admin_scripts','include_new_scripts',10,1);
?>

Parameters:None

Example:

<?php
add_action('orddd_include_admin_scripts','include_new_scripts',10,1);
function include_new_scripts(){
wp_enqueue_script(
'custom_js_script',
plugins_url( '/js/custom_js_script.js', __FILE__ ),
'',
'',
false );
....
}

orddd_plugin_activate: Use this hook to perform custom action when the plugin is activated.

Present in file: order-delivery-date.php

Usage:

<?php
add_action('orddd_plugin_activate','plugin_activate',10,1);
?>

Parameters:None

Example:

<?php
add_action('orddd_plugin_activate','plugin_activate',10,1);
function plugin_activate(){
add_option( 'custom_field_name', 'custom_value' );
...
}

orddd_plugin_deactivate: Use this hook to perform custom action when the plugin is deleted.

Present in file: order-delivery-date.php

Usage:

<?php
add_action('orddd_plugin_deactivate','plugin_deactivate',10,1);
?>

Parameters:None

Example:

<?php
add_action('orddd_plugin_deactivate','plugin_deactivate',10,1);
function plugin_deactivate(){
delete_option( 'custom_field_name');
...
}

Frontend display:

orddd_include_front_scripts: Use this hook to add additional scripts on the front end page along with the existing scripts used in the plugin.

Present in file: order-delivery-date.php

Usage:

<?php
add_action('orddd_include_front_scripts','include_new_scripts',10,1);
?>

Parameters:None

Example:

<?php
add_action('orddd_include_front_scripts','include_new_scripts',10,1);
function include_new_scripts(){
wp_enqueue_script(
'custom_js_script',
plugins_url( '/js/custom_js_script.js', __FILE__ ),
'',
'',
false );
....
}

orddd_before_checkout_delivery_date: Use this hook to add new fields before the Delivery date field on checkout page.

Present in file: orddd-process.php

Usage:

<?php
add_action('orddd_before_checkout_delivery_date','add_new_field_before',10,1);
?>

Parameters:None

Example:

<?php
add_action('orddd_before_checkout_delivery_date','add_new_field_before',10,1);
function add_new_field_before(){
...
}

orddd_after_checkout_delivery_date: Use this hook to add new fields after the Delivery date field on checkout page.

Present in file: orddd-process.php

Usage:

<?php
add_action('orddd_after_checkout_delivery_date','add_new_field_after',10,1);
?>

Parameters:None

Example:

<?php
add_action('orddd_after_checkout_delivery_date','add_new_field_after',10,1);
function add_new_field_after(){

...
}

orddd_before_checkout_time_slot: Use this hook to add new fields before the Time slot field on checkout page.

Present in file: orddd-process.php

Usage:

<?php
add_action('orddd_before_checkout_time_slot','add_new_field_before',10,1);
?>

Parameters:None

Example:

<?php
add_action('orddd_before_checkout_time_slot','add_new_field_before',10,1);
function add_new_field_before(){

...
}

orddd_after_checkout_time_slot: Use this hook to add new fields after the Time slot field on checkout page.

Present in file: orddd-process.php

Usage:

<?php
add_action('orddd_after_checkout_time_slot','add_new_field_after',10,1);
?>

Parameters:None

Example:

<?php
add_action('orddd_after_checkout_time_slot','add_new_field_after',10,1);
function add_new_field_after(){

...
}

orddd_before_date_validation: Use this hook to perform any action before mandatory field validation of date takes place on checkout page before order is placed.

Present in file: orddd-process.php

Usage:

<?php
add_action('orddd_before_date_validation','date_processing_function',10,1);
?>

Parameters:
$orddd_delivery_date – This contains the date selected from delivery date field.

Example:

<?php
add_action('orddd_before_date_validation','date_processing_function',10,1);
function date_processing_function($orddd_delivery_date){
/* perform your custom validation action with delivery date selected before any other validations happen*/
if($orddd_delivery_date == "" ) {
        /* example some javascript alert action */
}
...
}

orddd_after_date_validation: Use this hook to perform any action after mandatory field validation of date takes place on checkout page before order is placed.

Present in file: orddd-process.php

Usage:

<?php
add_action('orddd_after_date_validation','date_processing_function',10,1);
?>

Parameters:
$orddd_delivery_date – This contains the date selected from delivery date field.

Example:

<?php
add_action('orddd_after_date_validation','date_processing_function',10,1);
function date_processing_function($orddd_delivery_date){
 /* perform your action with delivery date selected after mandatory field validation completed sucessfully*/

/* example save Delivery Date in your custom table */
...
}

orddd_before_timeslot_validation: Use this hook to perform any action before mandatory field validation of timeslot takes place on checkout page before order is placed.

Present in file: orddd-process.php

Usage:

<?php
add_action('orddd_before_timeslot_validation','timeslot_processing_function',10,1);
?>

Parameters:
$orddd_timeslot – This contains the time slot selected from time slot field.

Example:

<?php
add_action('orddd_before_timeslot_validation','timeslot_processing_function',10,1);
function timeslot_processing_function($orddd_timeslot){
/* perform your custom validation action with timeslot selected before any other validations happen*/
if($orddd_timeslot == "" || $orddd_timeslot == 'choose' || $orddd_timeslot == 'NA' ) {
/* example some javascript alert action */
}
...
}

orddd_after_timeslot_validation: Use this hook to perform any action after mandatory field validation of timeslot takes place on checkout page before order is placed.

Present in file: orddd-process.php

Usage:

<?php
add_action('orddd_after_timeslot_validation','timeslot_processing_function',10,1);
?>

Parameters:
$orddd_timeslot – This contains the time slot selected from time slot field.

Example:

<?php
add_action('orddd_after_timeslot_validation','timeslot_processing_function',10,1);
function timeslot_processing_function($orddd_timeslot){
/* perform your action with timeslot selected after mandatory field validation completed sucessfully*/

/* example save Timeslots in your custom table */
...
}

orddd_after_delivery_date_update: Use this hook to perform custom action after Delivery Date information is updated in database.

Present in file: orddd-process.php

Usage:

<?php
add_action('orddd_after_delivery_date_update','process_date_after_update',10,1);
?>

Parameters:
$orddd_delivery_date- This contains the delivery date selected from delivery date field.

Example:

<?php
add_action('orddd_after_delivery_date_update','process_date_after_update',10,1);
function process_date_after_update($orddd_delivery_date){
/*store the delivery date in some custom table for later processing*/
...
}

orddd_after_timeslot_update: Use this hook to perform custom action after Timeslot information is updated in database.

Present in file: orddd-process.php

Usage:

<?php
add_action('orddd_after_timeslot_update','process_timeslot_after_update',10,1);
?>

Parameters:
$orddd_timeslot – This contains the time slot selected from time slot field.

Example:

<?php
add_action('orddd_after_timeslot_update','process_timeslot_after_update',10,1);
function process_timeslot_after_update($orddd_timeslot){
/*store the timeslot in some custom table for later processing*/
...
}

WooCommerce Delivery Date Filters:

Frontend:

orddd_add_delivery_date_fees: Use this hook to add additional fee along with delivery fees.

Present in file: orddd-process.php

Usage:

<?php
add_filter('orddd_add_delivery_date_fees','add_additional_charges',10,2);
?>

Parameters:
$order_delivery_date – This contains the delivery date selected on the checkout page.
$orddd_fees – This contains the delivery charges added for the selected date in admin panel.

Example:

<?php
add_filter('orddd_add_delivery_date_fees','add_additional_charges',10,2);
function add_additional_charges($order_delivery_date, $orddd_fees){
//Calculate the addition charges with delivery fees.....
return $orddd_fees;
}

orddd_email_before_delivery_date: Use this hook to add new fields in an email before the Delivery Date plugin fields, on placing the order.

Present in file: orddd-process.php

Usage:

<?php
add_filter('orddd_email_before_delivery_date','add_new_field_before',10,1);
?>

Parameters:
$keys – This is the default value used for adding fields in emails

Example:

<?php
add_filter('orddd_email_before_delivery_date','add_new_field_before',10,1);
function add_new_field_before($keys){
$keys[] = 'Custom field';
return $keys;
}

orddd_email_after_delivery_details: Use this hook to add new fields in an email after the Delivery Date plugin fields, on placing the order.

Present in file: orddd-process.php

Usage:

<?php
add_filter('orddd_email_after_delivery_details','add_new_field_after',10,1);
?>

Parameters:
$keys – This is the default value used for adding fields in emails

Example:

<?php
add_filter('orddd_email_after_delivery_details','add_new_field_after',10,1);
function add_new_field_after($keys){
$keys[] = 'Custom field';
return $keys;
}

orddd_before_delivery_date_update: Use this hook to perform custom action before Delivery Date information is updated in database.

Present in file: orddd-process.php

Usage:

<?php
add_filter('orddd_before_delivery_date_update','modify_date_before_update',10,1);
?>

Parameters:
$orddd_delivery_date – This contains the delivery date selected from delivery date field.

Example:

<?php
add_filter('orddd_before_delivery_date_update','modify_date_before_update',10,1);
function modify_date_before_update($orddd_delivery_date){
/*modify the delivery date to be saved if cart contains some products or products from certain categories*/
return $orddd_delivery_date;
}

orddd_before_timeslot_update: Use this hook to perform custom action before Timeslot information is updated in database.

Present in file: orddd-process.php

Usage:

<?php
add_filter('orddd_before_timeslot_update','modify_timeslot_before_update',10,1);
?>

Parameters:
$orddd_timeslot – This contains the time slot selected from time slot field.

Example:

<?php
add_filter('orddd_before_timeslot_update','modify_timeslot_before_update',10,1);
function modify_timeslot_before_update($orddd_timeslot){
/*modify the delivery timeslot to be saved if cart contains some products or products from certain categories*/
return $orddd_timeslot;
}

orddd_to_calculate_minimum_hours_for_disable_days: Use this hook to enable the calculation of Minimum delivery time (in hours) for disabled weekdays on the checkout page.

Present in file: orddd-process.php

Usage:

<?php
add_filter( 'orddd_to_calculate_minimum_hours_for_disable_days', 'calculate_minimum_hours_for_disable_days' );
?>

Parameters:
None

Example:

<?php
add_filter( 'orddd_to_calculate_minimum_hours_for_disable_days', 'calculate_minimum_hours_for_disable_days' );
function calculate_minimum_hours_for_disable_days() {
return 'yes';
}

orddd_change_same_day_delivery_charges_label: Use this hook to change the Same Day Delivery charges label on the checkout page.

Present in file: orddd-process.php

Usage:

<?php
add_filter('orddd_change_same_day_delivery_charges_label','orddd_same_day_delivery_charges_label');
?>

Parameters:
None

Example:

<?php
add_filter('orddd_change_same_day_delivery_charges_label','orddd_same_day_delivery_charges_label');
function orddd_same_day_delivery_charges_label() {
$same_day_delivery_charges_label = 'Today Delivery Charges';
return $same_day_delivery_charges_label;
}

orddd_change_next_day_delivery_charges_label: Use this hook to change the Next Day Delivery charges label on the checkout page.

Present in file: orddd-process.php

Usage:

<?php
add_filter('orddd_change_next_day_delivery_charges_label','orddd_next_day_delivery_charges_label');
?>

Parameters:
None

Example:

<?php
add_filter('orddd_change_next_day_delivery_charges_label','orddd_next_day_delivery_charges_label');
function orddd_next_day_delivery_charges_label() {
$next_day_delivery_charges_label = 'Tomorrow Delivery Charges';
return $next_day_delivery_charges_label;
}

orddd_shopping_cart_hook: Use this hook to change the field placement on the checkout page.

Present in file: orddd-process.php

Usage:

<?php
add_filter('orddd_shopping_cart_hook','orddd_shopping_cart_hook_function');
?>

Parameters:
None

Example:

<?php
add_filter( 'orddd_shopping_cart_hook', 'orddd_shopping_cart_hook_function' );
function orddd_shopping_cart_hook_function() {
$orddd_hook = 'woocommerce_review_order_before_payment';
return $orddd_hook;
}

orddd_to_calculate_minimum_hours_for_holidays: Use this hook to enable the calculation of Minimum delivery time (in hours) for holidays on the checkout page.

Present in file: orddd-process.php

Usage:

<?php
add_filter( 'orddd_to_calculate_minimum_hours_for_holidays', 'calculate_minimum_hours_for_holidays' );
?>

Parameters:
None

Example:

<?php
add_filter( 'orddd_to_calculate_minimum_hours_for_holidays', 'calculate_minimum_hours_for_holidays' );
function calculate_minimum_hours_for_holidays() {
return 'yes';
}

orddd_remove_delivery_date_if_product_category_no: Use this hook to disable the Delivery fields on the checkout page if any of the product with the category which has Delivery disabled is added to the cart.

Present in file: orddd-common.php

Usage:

<?php
add_filter( 'orddd_remove_delivery_date_if_product_category_no', 'remove_delivery_date_if_product_category_no' );
?>

Parameters:
None

Example:

<?php
add_filter( 'orddd_remove_delivery_date_if_product_category_no', 'remove_delivery_date_if_product_category_no' );
function remove_delivery_date_if_product_category_no() {
return 'yes';
}

orddd_add_delivery_charges_for_free_coupon_code: This hook allows adding delivery charges for the date even if the coupon code with Free Shipping is used on the checkout page.

Present in file: orddd-process.php, orddd-admin-delivery.php

Usage:

<?php
add_filter( 'orddd_to_add_delivery_charges_for_free_coupon_code', 'add_delivery_charges_for_free_coupon_code' );
?>

Parameters:
None

Example:

<?php
add_filter( 'orddd_to_add_delivery_charges_for_free_coupon_code', 'add_delivery_charges_for_free_coupon_code' );
function add_delivery_charges_for_free_coupon_code() {
    return 'yes';
}

orddd_common_delivery_days_for_product_category: This hook allows enabling only the common weekdays in the calendar when products from multiple product categories are added to the cart and Custom delivery settings are added for them.

Present in file: orddd-common.php

Usage:

<?php
add_filter( 'orddd_common_delivery_days_for_product_category', 'orddd_common_delivery_days_for_product_category_function' );
?>

Parameters:
None

Example:

<?php
add_filter( 'orddd_common_delivery_days_for_product_category', 'orddd_common_delivery_days_for_product_category_function' );
function orddd_common_delivery_days_for_product_category_function() {
    global $woocommerce, $wpdb, $orddd_weekdays;
    $common_delivery_days = $delivery_days = $shipping_settings = array();
    $delivery_type = '';
    $shipping_based_settings_query = "SELECT option_value, option_name FROM `" . $wpdb->prefix . "options` WHERE option_name LIKE 'orddd_shipping_based_settings_%' AND option_name != 'orddd_shipping_based_settings_option_key' ORDER BY option_id DESC";
    $results = $wpdb->get_results( $shipping_based_settings_query );
    if( get_option( 'orddd_enable_shipping_based_delivery' ) == 'on' && count( $results ) > 0 ) {
        foreach ( $results as $key => $value ) {
            $weekday_settings = array();
            $shipping_settings = get_option( $value->option_name );
            if ( isset( $shipping_settings[ 'delivery_settings_based_on' ][0] ) && $shipping_settings[ 'delivery_settings_based_on' ][0] == 'product_categories' && isset( $shipping_settings[ 'product_categories' ] ) ) {
                foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
                    $terms = get_the_terms( $values[ 'data' ]->id  , 'product_cat' );
                    if ( '' != $terms ) {
                        foreach ( $terms as $term => $val ) {
                            if ( in_array( $val->slug, $shipping_settings[ 'product_categories' ] ) ) {
                                if( isset( $shipping_settings[ 'delivery_type' ] ) ) {
                                    $delivery_type = $shipping_settings[ 'delivery_type' ];
                                }
                                if( isset( $delivery_type[ 'weekdays' ] ) && $delivery_type[ 'weekdays' ] == 'on' ) {
                                    foreach ( $orddd_weekdays as $n => $day_name ) {
                                        $weekday = $shipping_settings[ 'weekdays' ][ $n ];
                                        if( isset( $weekday[ 'enable' ] ) && $weekday[ 'enable' ] == 'checked' ) {
                                            $weekday_settings[ $n ] = $weekday[ 'enable' ];
                                        }
                                    }
                                    $delivery_days[] = $weekday_settings;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    if( count( $delivery_days )  > 0 ) {
        $i = 0; $j = 1;
        foreach( $delivery_days as $w_key => $w_value ) {
            if( isset( $delivery_days[ $i ] ) && isset( $delivery_days[ $j ] ) ) {
                $common_delivery_days = array_intersect_key( $delivery_days[ $i ], $delivery_days[ $j ] );
            }
            $i++;
            $j++;
        }
    }
    return $common_delivery_days;
}

orddd_edit_field_for_order_statuses: This hook will allow the customers to edit the Delivery Date & Time on the My account page only for the selected returned order statuses from this hook

Present in file: orddd-process.php

Usage:

<?php
add_filter( 'orddd_edit_field_for_order_statuses', 'orddd_edit_field_for_order_statuses_function' );
?>

Parameters:
None

Example:

<?php
add_filter( 'orddd_edit_field_for_order_statuses', 'orddd_edit_field_for_order_statuses_function' );
function orddd_edit_field_for_order_statuses_function() {
    $order_statuses_arr = array( 'wc-on-hold', 'wc-pending' );
    return $order_statuses_arr;
}

orddd_disable_delivery_for_user_roles: This hook allows to disable delivery date & time on the checkout page for certain user roles like Subscriber.

Present in file: orddd-process.php

Usage:

<?php
add_filter( 'orddd_disable_delivery_for_user_roles', 'orddd_disable_delivery_for_user_roles_function' );
?>

Parameters:
None

Example:

<?php
add_filter( 'orddd_disable_delivery_for_user_roles', 'orddd_disable_delivery_for_user_roles_function' );
function orddd_disable_delivery_for_user_roles_function() {
    $roles = array( 'subscriber', 'author', 'customer' );
    return $roles;
}

Settings Api Sections for WooCommerce Delivery Date Functions:

Use the below sections to add new fields at appropriate tabs within the order delivery date setting in admin.

orddd_date_settings_section: Use this section to add new field/s in ‘Order Delivery Date Settings’ section in Date settings tab.

Present in file: orddd-settings.php

Usage:

<?php
add_action( 'admin_init', 'orddd_new_date_settings');
function orddd_new_date_settings() {
add_settings_field(
'orddd_custom_field',
'Custom Field:',
'orddd_custom_field_callback',
'orddd_date_settings_page',
'orddd_date_settings_section',
array( 'Custom field' )
);

register_setting(
'orddd_date_settings',
'orddd_custom_field'
);
}

function orddd_custom_field_callback( $args ) {
printf(
'<input type="text" name="orddd_custom_field" id="orddd_custom_field" value="'.get_option( 'orddd_custom_field' ).'"    maxlength="40"/>'
);

$html = '<label for="orddd_custom_field"> '  . $args[0] . '</label>';
echo $html;
}

orddd_integration_with_other_plugins: Use this section to add new field/s in ‘Integration with Other Plugins’ section in Date settings tab.

Present in file: orddd-settings.php

Usage:

<?php
add_action( 'admin_init', 'orddd_new_date_settings',15);

function orddd_new_date_settings() {
add_settings_field(
'orddd_custom_field',
'Custom Field:',
'orddd_custom_field_callback',
'orddd_date_settings_page',
'orddd_integration_with_other_plugins',
array( 'Custom field' )
);

register_setting(
'orddd_date_settings',
'orddd_custom_field'
);
}

function orddd_custom_field_callback( $args ) {
printf(
'<input type="text" name="orddd_custom_field" id="orddd_custom_field" value="'.get_option( 'orddd_custom_field' ).'"    maxlength="40"/>'
);

$html = '<label for="orddd_custom_field"> '  . $args[0] . '</label>';
echo $html;
}

orddd_time_settings_section: Use this section to add new field/s in ‘Time Settings’ section in Time settings tab.

Present in file: orddd-settings.php

Usage:

<?php
add_action( 'admin_init', 'orddd_new_time_settings',15);

function orddd_new_time_settings() {
add_settings_field(
'orddd_custom_field',
'Custom Field:',
'orddd_custom_field_callback',
'orddd_time_settings_page',
'orddd_time_settings_section',
array( 'Custom field' )
);

register_setting(
'orddd_time_settings',
'orddd_custom_field'
);
}


function orddd_custom_field_callback( $args ) {
printf(
'<input type="text" name="orddd_custom_field" id="orddd_custom_field" value="'.get_option( 'orddd_custom_field' ).'"    maxlength="40"/>'
);

$html = '<label for="orddd_custom_field"> '  . $args[0] . '</label>';
echo $html;
}

orddd_same_day_delivery_section: Use this section to add new field/s in ‘Same Day Delivery’ section in Time settings tab.

Present in file: orddd-settings.php

Usage:

<?php
add_action( 'admin_init', 'orddd_new_time_settings',15);

function orddd_new_time_settings() {
add_settings_field(
'orddd_custom_field',
'Custom Field:',
'orddd_custom_field_callback',
'orddd_time_settings_page',
'orddd_same_day_delivery_section',
array( 'Custom field' )
);

register_setting(
'orddd_time_settings',
'orddd_custom_field'
);
}


function orddd_custom_field_callback( $args ) {
printf(
'<input type="text" name="orddd_custom_field" id="orddd_custom_field" value="'.get_option( 'orddd_custom_field' ).'"    maxlength="40"/>'
);

$html = '<label for="orddd_custom_field"> '  . $args[0] . '</label>';
echo $html;
}

orddd_next_day_delivery_section: Use this section to add new field/s in ‘Next Day Delivery’ section in Time settings tab.

Present in file: orddd-settings.php

Usage:

<?php
add_action( 'admin_init', 'orddd_new_time_settings',15);

function orddd_new_time_settings() {
add_settings_field(
'orddd_custom_field',
'Custom Field:',
'orddd_custom_field_callback',
'orddd_time_settings_page',
'orddd_next_day_delivery_section',
array( 'Custom field' )
);

register_setting(
'orddd_time_settings',
'orddd_custom_field'
);
}


function orddd_custom_field_callback( $args ) {
printf(
'<input type="text" name="orddd_custom_field" id="orddd_custom_field" value="'.get_option( 'orddd_custom_field' ).'"    maxlength="40"/>'
);

$html = '<label for="orddd_custom_field"> '  . $args[0] . '</label>';
echo $html;
}

orddd_holidays_section: Use this section to add new field/s in ‘Add Holiday’ section in Holidays tab.

Present in file: orddd-settings.php

Usage:

<?php
add_action( 'admin_init', 'orddd_new_holiday_settings',15);

function orddd_new_holiday_settings() {
add_settings_field(
'orddd_custom_field',
'Custom Field:',
'orddd_custom_field_callback',
'orddd_holidays_page',
'orddd_holidays_section',
array( 'Custom field' )
);

register_setting(
'orddd_holiday_settings',
'orddd_custom_field'
);
}


function orddd_custom_field_callback( $args ) {
printf(
'<input type="text" name="orddd_custom_field" id="orddd_custom_field" value="'.get_option( 'orddd_custom_field' ).'"    maxlength="40"/>'
);

$html = '<label for="orddd_custom_field"> '  . $args[0] . '</label>';
echo $html;
}

orddd_appearance_section: Use this section to add new field/s in ‘Calendar Apprearance’ section in Holidays tab.

Present in file: orddd-settings.php

Usage:

<?php
add_action( 'admin_init', 'orddd_new_appearance_settings',15);

function orddd_new_appearance_settings() {
add_settings_field(
'orddd_custom_field',
'Custom Field:',
'orddd_custom_field_callback',
'orddd_appearance_page',
'orddd_appearance_section',
array( 'Custom field' )
);

register_setting(
'orddd_appearance_settings',
'orddd_custom_field'
);
}

function orddd_custom_field_callback( $args ) {
printf(
'<input type="text" name="orddd_custom_field" id="orddd_custom_field" value="'.get_option( 'orddd_custom_field' ).'"    maxlength="40"/>'
);

$html = '<label for="orddd_custom_field"> '  . $args[0] . '</label>';
echo $html;
}

orddd_delivery_days_section: Use this section to add new field/s in ‘Add Specific Delivery Dates’ section in Holidays tab.

Present in file: orddd-settings.php

Usage:

<?php
add_action( 'admin_init', 'orddd_new_delivery_date_settings',15);

function orddd_new_delivery_date_settings() {
add_settings_field(
'orddd_custom_field',
'Custom Field:',
'orddd_custom_field_callback',
'orddd_delivery_days_page',
'orddd_delivery_days_section',
array( 'Custom field' )
);

register_setting(
'orddd_delivery_days_settings',
'orddd_custom_field'
);
}

function orddd_custom_field_callback( $args ) {
printf(
'<input type="text" name="orddd_custom_field" id="orddd_custom_field" value="'.get_option( 'orddd_custom_field' ).'"    maxlength="40"/>'
);

$html = '<label for="orddd_custom_field"> '  . $args[0] . '</label>';
echo $html;
}

orddd_time_slot_section: Use this section to add new field/s in ‘Time Slot Settings’ section in Holidays tab.

Present in file: orddd-settings.php

Usage:

<?php
add_action( 'admin_init', 'orddd_new_time_slot_settings',15);

function orddd_new_time_slot_settings() {
add_settings_field(
'orddd_custom_field',
'Custom Field:',
'orddd_custom_field_callback',
'orddd_time_slot_page',
'orddd_time_slot_section',
array( 'Custom field' )
);

register_setting(
'orddd_time_slot_settings',
'orddd_custom_field'
);
}

function orddd_custom_field_callback( $args ) {
printf(
'<input type="text" name="orddd_custom_field" id="orddd_custom_field" value="'.get_option( 'orddd_custom_field' ).'"    maxlength="40"/>'
);

$html = '<label for="orddd_custom_field"> '  . $args[0] . '</label>';
echo $html;
}


WooCommerce Delivery Date Functions:

orddd_get_order_delivery_date: Use this function to obtain Delivery Date information for a particular order.

Present in file: orddd-common.php

Usage:

<?php
$order_id = 786; /*sample order ID*/
$orddd_class = new orddd_common();
$delivery_date = $orddd_class->orddd_get_order_delivery_date($order_id);
?>

Parameters:
$order_id – This contains the order id for which delivery date is obtained.

orddd_get_order_timeslot: Use this function to obtain Time slot information for a particular order.

Present in file: orddd-common.php

Usage:

<?php
$order_id = 786; /*sample order ID*/
$orddd_class = new orddd_common();
$time_slot= $orddd_class->orddd_get_order_timeslot($order_id);
?>

Parameters:
$order_id – This contains the order id for which time slot is obtained.

Subscribe Now