I am working with WooCommerce Subscriptions and am trying to set it so that users can select their own start date using another plugin. Within the date picker plugin, if a user chooses a date within the middle of the month, the payments are supposed to be prorated and then the subscription starts on the first day of the next month. However, the plugin works to only start at the day the subscription starts. I am trying to adjust this so it chooses the start date of the first day of the next month. I have used this as reference - How to find first day of the next month and remaining days till this date with PHP
function woosubscriptions_custom_cart_next_payment_date( $start_pay_date , $recurring_cart){
foreach($recurring_cart->get_cart() as $cart_item_key => $cart_item){
if(isset($cart_item['start-subcription']) && !empty($cart_item['start-subcription'])){
$days_free_trial = WC_Subscriptions_Product::get_trial_length( $cart_item['data'] );
$start_subcription = $cart_item['start-subcription'];
if($days_free_trial > 0){
$start_subcription .= ' ' . $days_free_trial . ' days';
}
$offset=5*60*60; //converting 5 hours to seconds.
$start_pay_date = gmdate( 'Y-m-d H:i:s', strtotime($start_subcription) + $offset);
$first_day_next_month = ($start_pay_date, strtotime('first day of next month'));
break;
}
}
return $first_day_next_month;
}
add_filter( 'wcs_recurring_cart_next_payment_date', 'woosubscriptions_custom_cart_next_payment_date', 10 , 2);
It is not correctly getting the first day of next month.