YITH Subscription – Update Start Date Before Create

I'm setting up a subscription product using WooCommerce and YITH Subscriptions and trying to find a way to delay the start of the subscription to a specific month ( April 1st or Oct 1st - whichever comes next ). Really struggling to find any references out there for any hooks or overrides etc for YITH but I've seen it done before so hopefully it's not too difficult to do. Also i see you can manually change the subscription date from the backend, but need it to be automatic. So in theory it would work something like: Add subscription to cart. In checkout the below calculation is done and applied to the subscription settings before it is created. ` $mn = date("m"); // this month if ( date("m") >= 4 || date("m") < 10 ) { // if it's April - Sep, first sub in Oct this year $start = date("Y-m-d H:i:s", strtotime("1st October this year")); } else if ( date("m") >= 10 ) { $start = date("Y-m-d H:i:s", strtotime("1st April next year")); } else { $start = date("Y-m-d H:i:s", strtotime("1st April this year")); } ` As an update Trying the following. It updates the cart item and shows Oct 1st as the renew date but unfortunately once I've gone through checkout the original date remains. add_filter( 'woocommerce_add_cart_item', 'add_custom_cart_item_data', 10, 2 ); function add_custom_cart_item_data( $cart_item_data, $cart_item ) { $mn = date("m"); // this month if ( date("m") >= 4 || date("m") < 10 ) { // if it's April - Sep, first sub in Oct this year $start = strtotime("1st October this year"); } else if ( date("m") >= 10 ) { $start = strtotime("1st April next year"); } else { $start = strtotime("1st April this year"); } $cart_item_data["ywsbs-subscription-info"]["next_payment_due_date"] = $start; return $cart_item_data; }

Comment (0)

You’ll be in good company