The following is a list of all hooks present in the plugin. It is intended to guide developers who want to extend the functionality of the Product Delivery Date Pro for WooCommerce plugin.
add_filter( 'prdd_exclude_minimum_hours_for_disable_days', 'prdd_exclude_minimum_hours_for_disable_days_function', 10, 1 );
/**
* @param string $is_excluded yes - to exclude the disabled days | no - to not exclude the days
*/
function prdd_exclude_minimum_hours_for_disable_days_function( $is_excluded ) {
return 'yes';
}
prdd_add_days_to_holidays_function:
Loop through the existing holiday array and add one day to the holiday date if the cut-off time has passed.
add_filter( 'prdd_add_days_to_holidays', 'prdd_add_days_to_holidays_function', 10, 2 );
/**
* Checks if the next day is a holiday or not & disables it if store owner doesn't want to count cut-off time on holidays.
*
* @param array $disabled_days Existing disabled dates array.
* @param array $holiday_array Existing holidays dates array.
*/
function prdd_add_days_to_holidays_function( $disabled_days, $holiday_array ) {
if( !empty( $holiday_array ) ){
foreach( $holiday_array as $h ){
$h_date = date( 'j-n-Y', strtotime($h) );
if( in_array( $h_date, $holiday_array )){
$blocked_holiday = date( 'n-j-Y', strtotime( $h ) + 86400 );
$disabled_days[] = $blocked_holiday;
}
}
}
return $disabled_days;
}
3. prdd_add_days_to_disable_days_function:
add_filter( 'prdd_add_days_to_disable_days', 'prdd_add_days_to_disable_days_function', 10, 3 );
/**
* Checks, if the next day is working or not & disables it if store owner doesn't want to count cut-off time on non-working days.
*
* @param array $disabled_days Existing disabled date array.
* @param array $recurring_date Existing recurring date array.
* @param string $current_time Timestamp of current time.
*/
function prdd_add_days_to_disable_days_function( $disabled_days, $recurring_date, $current_time ) {
if( isset( $recurring_date ) && !empty( $recurring_date ) ) {
$daynum = date("N", time());
$day = 1;
$day_limit = 6;
for( $d = $daynum; $d <= $day_limit; $d++ ) {
if ( $recurring_date["prdd_weekday_".$d] == "" ){
if( $d < 7 ){
$disabled_days[] = date( 'n-j-Y', $current_time + ( 86400 * $day ) );
$day++;
}
else{
break;
}
}
if( $d == 6 ){
$d = 0;
$day_limit = $daynum - 1;
}
}
return $disabled_days;
}
}
4. To show the time slot as available until its end time
add_filter( 'prdd_endtime_for_timeslot', 'endtime_for_timeslot', 10, 1 );
/**
* @param string $endtime_for_timeslot True to show time slot till end.
*/
function endtime_for_timeslot( $endtime_for_timeslot ) {
return true;
}
add_filter( 'prdd_endtime_for_timeslot_starting_date', 'endtime_for_timeslot_starting_date', 10, 1 );
/**
* @param string $endtime_for_timeslot True to show time slot till end.
*/
function endtime_for_timeslot_starting_date( $endtime_for_timeslot_starting_date ) {
return true;
}
5. To change the edit deliveries button text in the cart, checkout, and my-account pages.
add_filter( 'prdd_edit_deliveries_button_text', 'prdd_edit_deliveries_button_text_callback' );
/**
* change Edit Deliveries button text in the cart, checkout, and my-account pages.
*/
function prdd_edit_deliveries_button_text_callback(){
return "New button text";
}
6. Change the edit deliveries in the edit modal title text in the cart, checkout, and my-account pages.
add_filter( 'prdd_edit_deliveries_modal_title', 'prdd_edit_deliveries_modal_title_callback' );
/**
* Change Edit Deliveries of edit modal title text in the cart, checkout, and my-account pages.
*/
function prdd_edit_deliveries_modal_title_callback(){
return "New modal title";
}
7. To change the button text in the edit modal of the cart, checkout, and my-account pages.
add_filter( 'prdd_confirm_deliveries_button_text', 'prdd_confirm_deliveries_button_text_callback' );
/**
* Change Edit Deliveries button text of edit modal of the cart, checkout, and my-account pages.
*/
function prdd_confirm_deliveries_button_text_callback() {
return "Save Pickup Details";
}
8. To change the ‘Cancel’ button text in the edit modal popup in the cart, checkout, and my-account pages.
add_filter( 'prdd_edit_popup_cancel_button_text', 'prdd_edit_popup_cancel_button_text_callback' );
/**
* change the Cancel button of Edit Deliveries popup text in the cart, checkout, and my-account pages.
*/
function prdd_edit_popup_cancel_button_text_callback(){
return "Close";
}
9. To hide the stock count on the product page.
add_filter('prdd_hide_stock_count', 'prdd_hide_stock_count_callback');
/**
* Hide stock count digit on the product page.
*/
function prdd_hide_stock_count_callback(){
return 'yes';
}
10. To not create any order when the delivery date is changed from the edit-order page.
add_filter('prdd_create_new_order_on_date_reschedule', 'prdd_create_new_order_on_date_reschedule_callback');
/**
* It will not allow creating an order when we reschedule the order by changing its delivery date.
*/
function prdd_create_new_order_on_date_reschedule_callback(){
return "no";
}
11. To change the text on the product page if the same date for all products option is enabled.
add_filter('prdd_duplicates_date_note_text', 'prdd_duplicates_date_note_text_callback');
/**
* It will change the text which is displayed on the product page.
*/
function prdd_duplicates_date_note_text_callback(){
return __( 'Delivery date has been populated from the products added in cart previously. Selecting a delivery date here would change the delivery date of all the other products.', 'woocommerce-prdd' );
}
12. To change the time of the Google event in the calendar while adding an event.
add_filter( 'prdd_default_time_slot_for_event', 'prdd_default_time_slot_for_event_callback', 10, 1 );
function prdd_default_time_slot_for_event_callback( $time_array ) {
$time_array = array( 'start_hour' => 11, 'start_min' => 30, 'end_hour' => 13, 'end_min' => 30 );
return $time_array;
}
13. To change the validation error message of the delivery date
add_filter( 'prdd_date_validation_message', 'prdd_date_validation_message_callback', 10, 2 );
function prdd_date_validation_message_callback( $delivery_date_validation_message, $delivery_date_label ) {
return "<b>" . $delivery_date_label . "</b>" . " is a required field. Please select it.";
}
14. To change the validation error message of the delivery time
add_filter( 'prdd_time_validation_message', 'prdd_time_validation_message_callback', 10, 2 );
function prdd_time_validation_message_callback( $delivery_time_validation_message, $delivery_time_label ) {
return "<b>" . $delivery_time_label . "</b>" . " is a required field. Please select it.";
}