Things that will need to be done:
- Unhook the
WC_Subscriptions::maybe_empty_cart()
and replace it with a similar function that doesn't empty the cart when a subscription is added (but does still callWC_Subscriptions::remove_subscriptions_from_cart()
if the cart contains a subscription (WC_Subscriptions_Cart::cart_contains_subscription()
) - You probably also want to remove the redirection to the checkout page immediately after a subscription is added to the cart. To do that, remove the
WC_Subscriptions::add_to_cart_redirect()
function from the'add_to_cart_redirect'
hook, or if you want to redirect to the cart page, use similar code to this: https://gist.github.com/thenbrent/7254424 - Make sure the totals are calculated correctly. This is the hard part. More details below.
- Make sure order line items show up correctly after purchase - I don't think you'll need to change anything here, hopefully it will just work.
To understand how totals are calculated, refer to the following functions:
- `