Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Alters the Next Occurrence Date for a Scheduled Order based on custom field.
- * @param array $scheduled_order_data The Scheduled Order Data to be sent to API.
- * @param int The current WC Order ID.
- * @return array The filtered Scheduled Order Data.
- */
- function xx_adjust_next_scheduled_order_date( $scheduled_order_data, $order_id ){
- // Make some call to check the custom Datepicker field & then convert to UTC
- // Date Time String.
- $value = get_post_meta( $order_id, 'xx_custom_date_picker_field' );
- // Adjust the NextOccurrenceUtc to match the custom value.
- // Get the Date into the Date Time String the API expects
- $order_date = new WC_DateTime( $value );
- $scheduled_order_data['NextOccurrenceUtc'] = $order_date->format('Y-m-d\TH:i:s');
- return $scheduled_order_data;
- }
- add_filter( 'autoship_create_scheduled_order_data', 'xx_adjust_next_scheduled_order_date', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement