Reputation: 21
Using WooCommerce Subscriptions plugin:
I'm looking for a way to automatically make the start date (and therefore end date) of a simple subscription.
We've tried renewal sync of payment dates but for various reasons we've changing to subscriptions that don't renew but only last for 1 year. A new order would then be needed after that (there were issues with renewals for this customer).
The customer wants all subscriptions to expire on 31-dec, no matter when they bought it.
I assume there's a way to do it through the functions.php file but I can't find any documentation that helps.
Does anyone know how we can modify the start date when an order is created?
Thanks.
Upvotes: 2
Views: 2146
Reputation: 352
// validate the start_date field
if ( ! is_string( $args['start_date'] ) || false === wcs_is_datetime_mysql_format( $args['start_date'] ) ) {
return new WP_Error( 'woocommerce_subscription_invalid_start_date_format', _x( 'Invalid date. The date must be a string and of the format: "Y-m-d H:i:s".', 'Error message while creating a subscription', 'woocommerce-subscriptions' ) );
} else if ( wcs_date_to_time( $args['start_date'] ) > current_time( 'timestamp', true ) ) {
return new WP_Error( 'woocommerce_subscription_invalid_start_date', _x( 'Subscription start date must be before current day.', 'Error message while creating a subscription', 'woocommerce-subscriptions' ) );
}
Upvotes: 0