Derek Joseph Olson
Derek Joseph Olson

Reputation: 778

Recurly - How to update subscription add on quantity?

$updateaddon = $subscription->subscription_add_ons[0];
$updateaddon->quantity = $extra_dashboard_count;
$subscription->subscription_add_ons[0] = $updateaddon;
try
{
    $subscription->updateAtRenewal();
}
catch(Exception $e)
{
    $error = $e->getMessage();
}

I'm getting an error message saying "Quantity must be equal to 1."

I'm following the PHP SDK example found here. They show updating existing add on quantity. Am I doing something wrong in code or why can I not have quantity greater than 1 for an add on?

Upvotes: 0

Views: 213

Answers (2)

Ben Hulan
Ben Hulan

Reputation: 547

If you update the quantity of a subscription with add-ons, you are literally adding multiple instances of that add-on.

But if it's a single instance of a usage-based add-on you need to update usage records directly.

Upvotes: 1

Derek Joseph Olson
Derek Joseph Olson

Reputation: 778

I don't see this mentioned anywhere in API documentation, but usage based add ons can't have their quantity increased. Instead you need to log the usage of the add on. API docs for logging add ons is found here

Upvotes: 0

Related Questions