Creating Custom Fullfilment Orders – Auto Set Next Date
-
Looking for a sanity check on some tweaks to WooCommerce Subscriptions. We are creating custom fulfillment orders and want to automatically generate new fulfillment orders based on the sign-up date.
If the customer joins before the 10th, set the fulfillment date to the 10th of the next month.
If the customer joins after the 10th, set the fulfillment date to the 10th of the month after next (+2 months).
Ex: If the sign-up date is Jan 5, Fulfillment date is Feb 10. If sign-up date is Jan 15, Fulfillment date is Mar 10.
I think the below code should work but not sure about the strtotime modifications. Any suggestions?
————————————–
$item_id = WC_Subscriptions_Order::get_item_id_by_subscription_key( $subscription_key ); $current_fulfillment = strtotime( wc_get_order_item_meta( $item_id, '_subscription_next_fulfillment_date' ) ); if ( empty( $current_fulfillment ) ) $current_fulfillment = strtotime( $subscription['start_date'] ); $day = date( "d",$current_fulfillment ); if ($day >= '10') { $next_fulfillment = strtotime( '10' . ('+1 ' . $subscription['period']), $current_fulfillment ); } else { $next_fulfillment = strtotime( '10' . ('+2 ' . $subscription['period']), $current_fulfillment ); }
——————————–
- The topic ‘Creating Custom Fullfilment Orders – Auto Set Next Date’ is closed to new replies.