mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Linked comped members to default product for imports
refs https://github.com/TryGhost/Team/issues/765 As part of the multiple products feature, we're not longer using Stripe subscriptions to denote Complimentary access, instead we're linking members directly to products. Here we update the importer to follow suit, so long as the flag is enabled.
This commit is contained in:
parent
9fc69d8f07
commit
b197d71c4e
1 changed files with 16 additions and 1 deletions
|
@ -109,6 +109,12 @@ module.exports = class MembersCSVImporter {
|
|||
|
||||
const membersApi = await this._getMembersApi();
|
||||
|
||||
const defaultProductPage = await membersApi.productRepository.list({
|
||||
limit: 1
|
||||
});
|
||||
|
||||
const defaultProduct = defaultProductPage.data[0];
|
||||
|
||||
const result = await rows.reduce(async (resultPromise, row) => {
|
||||
const resultAccumulator = await resultPromise;
|
||||
|
||||
|
@ -142,7 +148,16 @@ module.exports = class MembersCSVImporter {
|
|||
member_id: member.id
|
||||
}, options);
|
||||
} else if (row.complimentary_plan) {
|
||||
if (!labsService.isSet('multipleProducts')) {
|
||||
await membersApi.members.setComplimentarySubscription(member, options);
|
||||
} else {
|
||||
await membersApi.members.update({
|
||||
products: [{id: defaultProduct.id}]
|
||||
}, {
|
||||
...options,
|
||||
id: member.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
await trx.commit();
|
||||
|
|
Loading…
Add table
Reference in a new issue