I have Woo-commerce installed
I have Woo-commerce subscriptions installed
I have Woo-commerce stripe checkout installed.
I go through the checkout procedure and and I get the error “Subscription start date must be before the current day”
I have went through all the settings and I can’t see any option where I can set a start date, it is meant to start when the subscription starts.
I’ve reinstalled everything and insalled everything but I keep getting the same error.
here is a copy of my configuration.
I’ve tried googling everything but I can’t see this error ever before.
I’ve tried changing the UTC clock in the Dashboard->Settings->General but I still get the same error.
Here is the offending code
function wcs_create_subscription( $args = array() ) {
$order = ( isset( $args['order_id'] ) ) ? wc_get_order( $args['order_id'] ) : null;
$default_args = array(
'status' => '',
'order_id' => 0,
'customer_note' => null,
'customer_id' => ( ! empty( $order ) ) ? $order->get_user_id() : null,
'start_date' => ( ! empty( $order ) ) ? $order->order_date : current_time( 'mysql', true ),
'created_via' => ( ! empty( $order ) ) ? $order->created_via : '',
'order_version' => ( ! empty( $order ) ) ? $order->order_version : WC_VERSION,
'currency' => ( ! empty( $order ) ) ? $order->order_currency : get_woocommerce_currency(),
'prices_include_tax' => ( ! empty( $order ) ) ? ( ( $order->prices_include_tax ) ? 'yes' : 'no' ) : get_option( 'woocommerce_prices_include_tax' ),
);
$args = wp_parse_args( $args, $default_args );
$subscription_data = array();
// 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', __( 'Invalid date. The date must be a string and of the format: "Y-m-d H:i:s".', 'woocommerce-subscriptions' ) );
} else if ( strtotime( $args['start_date'] ) > current_time( 'timestamp', true ) ) {
return new WP_Error( 'woocommerce_subscription_invalid_start_date', __( 'Subscription start date must be before current day', 'woocommerce-subscriptions' ) );
}
until this is patched change this line (line 119 for me)
to this
The value of $order->order_date from a Woo Commerce class did not contain a timezone format so when this time was compared with the function current_time, the value contained a future date from my servers current time zone.
In WordPress general settings change your time to UTC(+or-#)to equal your current time and it should fix the problem. At least it did for me just now…