yarn add @pinelab/vendure-plugin-selectable-gifts
to install this plugin.
yarn add @pinelab/vendure-plugin-selectable-gifts
to install this plugin.
Vendure plugin to allow your loyal customers to select gifts when they placed more than X orders, or to select a gift when their order value is over $50.
When customer placed more than {minimum} orders
Just add the plugin to the plugins in your vendure-config.ts
:
import { SelectableGiftsPlugin } from '@pinelab/vendure-plugin-selectable-gifts';
plugins: [SelectableGiftsPlugin],
If customer placed more than { amount } orders
, and fill out the number you'd like, e.g. 'placed more than 5 orders'.Allow selected products as free gift
to the Promotion and select which variants should be selectable as gift.You can use different conditions for the free gifts, but the promotion needs to have the selectable_gifts action, in order for the eligibleGifts
query to work.
eligibleGifts
to show a list of eligible gifts to your customer:{
eligibleGifts {
id
name
sku
priceWithTax
}
}
addSelectedGiftToOrder
mutation:mutation addSelectedGiftToOrder($productVariantId: ID!) {
addSelectedGiftToOrder(productVariantId: $productVariantId) {
... on Order {
id
code
totalWithTax
lines {
id
quantity
linePriceWithTax
discountedUnitPriceWithTax
discountedLinePriceWithTax
productVariant {
id
name
sku
}
customFields {
isSelectedAsGift
}
}
discounts {
amount
amountWithTax
description
}
}
... on ErrorResult {
errorCode
message
}
}
}
discountedLinePriceWithTax
of €0,-customField.isSelectedAsGift = true
. The quantity of that order line will always be 1.const orderLineWithGift = order.lines.find(
(l) => l.customFields.isSelectedAsGift
);
You can create multiple promotions with different gifts to support different gift tiers. For example:
When a customer has over 5 placed orders, the eligibleGifts
query will return gifts A, B, C, X, Y and Z, because both promotion conditions are met. However, only 1 gift can be added to the order, even though the gifts come from 2 different promotions.
ℹ️ Only 1 gift can be added to an order at any given time. Selecting a new gift will remove the other selected gift.
If you don't want tier 2 to have tier 1 gifts, you can set a maximum in your promotion condition. It would then look like this: