Skip to content

Instantly share code, notes, and snippets.

@btribouillet
Created October 15, 2018 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btribouillet/104865353f76185e4f9776ea250c0ac7 to your computer and use it in GitHub Desktop.
Save btribouillet/104865353f76185e4f9776ea250c0ac7 to your computer and use it in GitHub Desktop.
Feature request : apply_filters on delivery date & delivery time
/**
* Update order delivery time with value from location cookie
*
* @param $value
* @return mixed
*/
function update_order_delivery_time( $value ) {
$location = Vmm_Helpers::get_location();
if( isset( $location['timeslot'] ) ) {
$value = $location['timeslot'];
}
return $value;
}
add_action( 'iconic_wds_update_order_delivery_time', 'update_order_delivery_time' );
/**
* Helper: Update order meta on successful checkout submission
*
* @param int $order_id
*/
function update_order_meta( $order_id ) {
$timeslot = false;
$posted_date = apply_filters( 'iconic_wds_update_order_delivery_date', filter_input( INPUT_POST, 'jckwds-delivery-date', FILTER_SANITIZE_STRING ) );
$posted_date_ymd = apply_filters( 'iconic_wds_update_order_delivery_date_ymd', filter_input( INPUT_POST, 'jckwds-delivery-date-ymd', FILTER_SANITIZE_STRING ) );
$posted_time = apply_filters( 'iconic_wds_update_order_delivery_time', filter_input( INPUT_POST, 'jckwds-delivery-time', FILTER_SANITIZE_STRING ) );
$date_changed = (int) filter_input( INPUT_POST, 'jckwds-date-changed', FILTER_SANITIZE_NUMBER_INT );
if ( empty( $posted_date ) || empty( $posted_date_ymd ) ) {
return;
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment