There is lack of document from TeaCommerce to create gift card. Could anyone can instruct me how to work with gift card by answer my following question?
I create Gift card as product with amount 50$, how can I generate unique gift card code after every time customer buy gift card?
Is it possible to send invoice and gift card code in separate emails? And how to do that?
Yea, unfortunately we don't have a lot of documentation in this area at the moment but it is something we are working to address.
In terms of how this would work though, what you would need to do is use the TC events ( https://docs.teacommerce.net/3.3.2/api/events/ ) to listen for an order which has just finalized, with a product of type "GiftCard" and then for each one, run GiftCardService.Instance.Generate(storeId, currencyId, amount, orderId); to generate the gift card. This will return the GiftCard entity, on which you will find the git card code.
To send a secondary email, setup a template in TC settings section, then as part of the same event handler above, once you have the gift card you can send an email using that template by calling something like EmailTemplateService.Instance.Get(storeId, emailtTemplateId).Send(giftCard, order.PaymentInformation.Email, order.LanguageId);
This will pass the gift card as the model to the email template, but that model can be whatever you want it to be so you could bundle up the order and the gift card into a custom object to pass through should you want to display properties from both entities in the email.
How to create Gift card
Hi,
There is lack of document from TeaCommerce to create gift card. Could anyone can instruct me how to work with gift card by answer my following question?
I create Gift card as product with amount 50$, how can I generate unique gift card code after every time customer buy gift card?
Is it possible to send invoice and gift card code in separate emails? And how to do that?
Regards, Linh
Hi Linh,
Yea, unfortunately we don't have a lot of documentation in this area at the moment but it is something we are working to address.
In terms of how this would work though, what you would need to do is use the TC events ( https://docs.teacommerce.net/3.3.2/api/events/ ) to listen for an order which has just finalized, with a product of type "GiftCard" and then for each one, run
GiftCardService.Instance.Generate(storeId, currencyId, amount, orderId);
to generate the gift card. This will return theGiftCard
entity, on which you will find the git card code.To send a secondary email, setup a template in TC settings section, then as part of the same event handler above, once you have the gift card you can send an email using that template by calling something like
EmailTemplateService.Instance.Get(storeId, emailtTemplateId).Send(giftCard, order.PaymentInformation.Email, order.LanguageId);
This will pass the gift card as the model to the email template, but that model can be whatever you want it to be so you could bundle up the order and the gift card into a custom object to pass through should you want to display properties from both entities in the email.
Hop this helps
Matt
is working on a reply...