Expected duration: 1 - 2 weeks We are running a Woocommerce store and sell subscriptions using the Woocommerce Subscriptions plugin. The task we are trying to accomplish is combining two, currently separate transaction types (Resubscribe or Renewal & Switch), into one process.
Each of our subscriptions has several variations, with different pricing for each. We have many customers who are happy with their subscription and wish to renew at the end of their term, but oftentimes wish to change to a different subscription variation at the same time. Currently, this can only be done as two separate checkout processes and the customer must first renew or resubscribe, and then do a subscription switch as a second process.
Progress to this point: Using Woocommerce actions and filters (specially hooking woocommerce_add_cart_item_data) we were able to make it work for a subscription switch , so:
1) We have implemented in the checkout page a form to allow the user to change the product in the cart using wp_ajax_woocommerce_ajax_add_to_cart 2) If the user wants to change the product assigned to the variable subscription during the switch checkout, we clean the existing cart (because we only allow 1 product purchase per order) and we add the newly selected product and variation to the cart via ajax 3) After that, we use the hook woocommerce_add_cart_item_data to overwrite the array $cart_item_data['subscription_switch’] which stores: subscription_id, item_id, next_payment_timestamp and upgraded_or_downgraded 4) The process looks like is working well after a couple of tests.
The problem we have found is that a similar process is not working for the resubscribe process, because looks like the $cart_item_data[’subscription_resubscribe’] array data does not include the ‘item_id’ so we cannot assign a new item product to the existing subscription (which is also expired, because is a resubscribe operation).
We are also using the plugin Calculated Fields Form (https://wordpress.org/plugins/calculated-fields-form/) for the pricing table design which will need to be considered.