• Resolved amirhmoradi

    (@amirhmoradi)


    Hi,
    When creating a subscription using the API on Woocommerce Subscriptions 4.1.0, the trial_end_date parameter 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.php

    On 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_date value 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"
    }
Viewing 1 replies (of 1 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi @amirhmoradi,

    Thank you for getting in touch!

    It sounds like you’re reporting an issue related to WooCommerce Subscriptions which is a marketplace extension whose support is not covered on this specific forum.

    Please contact us at WooCommerce.com > My Account > Support.

    You may need to log into your WooCommerce.com account before you can access that page.

    Also, don’t forget to include a link to this forum thread, so that we can keep track of what’s already been done.

    Thanks!

Viewing 1 replies (of 1 total)

The topic ‘Woocommerce Subscriptions API trial_end_date error’ is closed to new replies.