Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support items on subscriptions #508

Merged
merged 1 commit into from
Jun 30, 2020
Merged

Support items on subscriptions #508

merged 1 commit into from
Jun 30, 2020

Conversation

joannasese
Copy link
Contributor

@joannasese joannasese commented Jun 24, 2020

This PR adds support for items on subscriptions, where merchants may now associate a subscription add-on with an item in their catalog.

allow_any_item_on_subscriptions has been added to the Plan class. It is used to determine whether items can be assigned as add-ons to individual subscriptions. If true, items can be assigned as add-ons to individual subscription add-ons. If false, only plan add-ons can be used.

add_on_source, added to the SubscriptionAddOn class, is used to determine where the associated add-on data is pulled from. If this value is set to plan_add_on or left blank, then add-on data will be pulled from the plan's add-ons. If the associated plan has allow_any_item_on_subscriptions set to true and this field is set to item, then the associated add-on data will be pulled from the site's item catalog.

Code example:

// create sub add-on from item
$addon1 = new Recurly_SubscriptionAddOn();
$addon1->add_on_code = $item->item_code;
$addon1->add_on_source = "item";
$addon1->unit_amount_in_cents = 299;

// create sub add-on from existing add-on
$addon2 = new Recurly_SubscriptionAddOn();
$addon2->add_on_code = $add_on_2->add_on_code;

// create subscription
$subscription = new Recurly_Subscription();
$subscription->plan_code = $plan->plan_code;
$subscription->currency = 'USD';
$subscription->account = $account;
$subscription->subscription_add_ons = array($addon1, $addon2);
$subscription->create();

@joannasese joannasese added the V2 V2 Client label Jun 24, 2020
@joannasese joannasese marked this pull request as ready for review June 25, 2020 17:11
@joannasese joannasese requested a review from bhelx June 25, 2020 17:12
Copy link
Contributor

@bhelx bhelx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@bhelx bhelx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bhelx bhelx merged commit 746590c into v2 Jun 30, 2020
@bhelx bhelx deleted the dx-1581-items-on-subs branch June 30, 2020 01:30
@joannasese joannasese mentioned this pull request Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants