0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -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:
Fabien O'Carroll 2021-06-22 12:50:03 +01:00 committed by naz
parent 775b4a24f9
commit 4141fd1e6a

View file

@ -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) {
await membersApi.members.setComplimentarySubscription(member, options);
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();