Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Linh Le 10 posts 121 karma points
    Dec 11, 2019 @ 10:04
    Linh Le
    0

    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

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Dec 11, 2019 @ 14:02
    Matt Brailsford
    101

    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 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.

    Hop this helps

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft