Woocommerce Subscriptions API trial_end_date error
-
Hi,
When creating a subscription using the API on Woocommerce Subscriptions 4.1.0, thetrial_end_dateparameter documented in the official docs do not work.Here is the fix (I hope the team will fix it in next releases):
Using WordPress Plugin Editor (or any other editor), go to file :
<YOUR_WP_PLUGINS_DIR>/woocommerce-subscriptions/includes/api/class-wc-rest-subscriptions-controller.phpOn line 264, change:
case 'trial_end':
to:
case 'trial_end_date':On line 416, change:
'trial_date' => array(
to:
'trial_end_date' => array(Now, you can create a subscription and set the
trial_end_datevalue in your API request correctly.NB: The official documentation is not correct in the variable names that should be used.
See this working example:
POST example.com/wc/v3/subscriptions
BODY <json>:{ "status":"active", "billing": { "country": "FR" }, "shipping": { "country": "FR" }, "customer_id": 31, "line_items": [ {"product_id":1853 ,"quantity": 1} ], "set_paid":false, "parent_id": 2506, "trial_end_date": "2022-05-15 17:00:00", "next_payment_date": "2022-05-15 17:00:00", "billing_period": "year", "billing_interval": "1" }
The topic ‘Woocommerce Subscriptions API trial_end_date error’ is closed to new replies.