The next payment date requires a DateTime, and when looking at the codebase of the WooCommerce integration, we did not change this recently. I understand that in many cases it will be faster to just set the date, but I’m not sure if changing it now is the right way. We already have some hooks that you can use to change the field type and save the value. If you use a hook to change the DateTime field to a date field for this WC column, you also need to change the save value just before it is saved, because WC throws an error when the date is not a date with time. The following snippet will change the field to a date field and saved the correct value:
—
add_filter( 'acp/editing/view_settings', function ( $view, AC\Column $column ) {
if ( $column instanceof ACA\WC\Column\ShopSubscription\NextPaymentDate ) {
$view['type'] = 'date';
}
return $view;
}, 10, 2 );
add_filter( 'acp/editing/save_value', function ( $value, AC\Column $column, $id ) {
if ( $value && $column instanceof ACA\WC\Column\ShopSubscription\NextPaymentDate ) {
// Add time to the date so that WC can store the date correctly
$currentDate = $column->get_raw_value( $id );
$dateTime = DateTime::createFromFormat( 'Y-m-d H:i:s', $currentDate );
$value .= $dateTime !== false ? $dateTime->format( 'H:i:s' ) : '00:00:00';
}
return $value;
}, 10, 3 );
—