Developer forum

Forum » Templates » Gift Card tags in e-mail

Gift Card tags in e-mail

Christian Hansen Nørgaard
Reply

Hi DW.

I am trying to include the Gift Card code in my order receipt but it simply won't show. In my last step of the checkout flow I am showing the customers Receipt and I can get the Gift Card tags fine here:

if (!String.IsNullOrEmpty(GetString("Ecom:Order.HasGiftCards")))
{
    foreach (var gc in GetLoop("GiftCards"))
    {
        <h2>@gc.GetString("Ecom:Order.GiftCard.Name")</h2>
        <p><b>@Translate("giftcardcode", "GiftCard code")</b></p>
        <p>@gc.GetString("Ecom:Order.GiftCard.Code")</p>
        <p><b>@Translate("expirydate", "Expiry Date")</b></p>
        <p>@gc.GetDate("Ecom:Order.GiftCard.ExpiryDate").ToString("dd MMM yyyy")</p>
    }
}

But when I try to use the above in my e-mail template receipt it simply does'nt show.

if (!String.IsNullOrEmpty(GetString("Ecom:Order.HasGiftCards")))
{
    <tr>
        @foreach (var gc in GetLoop("GiftCards"))
        {
            <td colspan="3">@Translate("giftcardcode", "GiftCard code"): @gc.GetString("Ecom:Order.GiftCard.Code")</td>
            <td colspan="3">@Translate("expirydate", "Expiry Date"): @gc.GetDate("Ecom:Order.GiftCard.ExpiryDate").ToString("dd MMM yyyy")</td>
        }
    </tr>
}

I've also tried tying it to my orderline loop like; foreach (LoopItem ol in GetLoop("OrderLines")) -> ol.GetString("Ecom:Order.HasGiftCards") and ol.GetLoop("GiftCards") but none of the attempts works. Can you please direct me towards the correct tags in the e-mail receipt?


Replies

 
Merethe Vrå Andersen Dynamicweb Employee
Merethe Vrå Andersen
Reply

Hi Christian,

I have attached a Wrap order reciept template and order email template where bought gift cards and used gift cards are rendered. I have also attached screenshots of the part of the emails where gift card information are rendered.

I hope that this can help you with your problem.

Kind regards,
Merethe

giftcardsbought.jpg giftcardsused.jpg
 
Christian Hansen Nørgaard
Reply

Hi Merethe.

Many thanks for the templates and screenies. :) I will have to try it again.

Could I bother you to provide the example template of ShowCart? I have some trouble handling if the giftcard value is higher than the actual purchase, and would like to see how it's set up.

Regards,

Christian

 
Merethe Vrå Andersen Dynamicweb Employee
Merethe Vrå Andersen
Reply

Hi,

Here you go :)

/Merethe

 
Merethe Vrå Andersen Dynamicweb Employee
Merethe Vrå Andersen
Reply

And as answer I have attached a screenshot: If you buy a product that costs 37,49 kr, and you use a 50 kr giftcard, then it withdraws 37,49 from the giftcard and stores the remaining amount (12,51).

giftcard.jpg
 
Christian Hansen Nørgaard
Reply

I don't know what is going wrong but I can't seem to get the correct values when I want to use my GiftCard..

I have a GiftCard of 2.140 kr., and I add it to my cart by using the <input type="text" name="EcomOrderGiftCardCode" id="EcomOrderGiftCardCode" value="@GetString("Ecom:Order.GifTCardCode")" onblur="updateCart();" /> field. I've added onblur="updateCart();" to it so the cart will actually update with the GiftCard when the user "exits" the field.

I should mention that I am using a single page/Step for both Information and ShowCart.

When the GiftCard is added to the cart as a product though the above input text field it has the amount 2.140 kr. My Subtotal and Total is 0, but I don't see any tags that will show how much the products combined discount is. E.g. I've added a product with a price of 1.250 and another with a price of 187,50. The only tag I can see that makes a bit of sense is Ecom:Order.OrderLines.TotalDiscount but this also only shows the GiftCard full amount. Please see attached screen.

If I click the "Go to payment" button I am getting an error about a total amount of 0. Should I skip the payment provider step if the amount is 0?

Regards,

Christian

 
Merethe Vrå Andersen Dynamicweb Employee
Merethe Vrå Andersen
Reply

Hi,

Yes, you need to enable "Skip payment gateway if order amount is 0 or less" in shopping cart settings (screenshot). Then it use the default payment payment provider and completes the order.

/Merethe

skippayment.jpg
 
Christian Hansen Nørgaard
Reply

Great, thanks. :) For all your help actually.

 
Merethe Vrå Andersen Dynamicweb Employee
Merethe Vrå Andersen
Reply

You're welcome :)

 
Christian Hansen Nørgaard
Reply

Sadly I am still not able to retrieve anything from the giftcard loops in mails or Print (PrintOrder.cshtml)

            @{ 
                string code = "";
                foreach (LoopItem usedgiftcards in GetLoop("UsedGiftCards"))
                {
                    code = usedgiftcards.GetString("Ecom:Order.UsedGiftCard.Code");
                }
            }

            <td>@code</td>

The string code is simply empty. It works fine in my Receipt.cshtml

 
Merethe Vrå Andersen Dynamicweb Employee
Merethe Vrå Andersen
Reply

These steps are working?

  • buy a gift card and complete the order
  • reciept in browser shows gift card code (the bought gift card appers in the gift cards list in the backend), 
  • email shows the code too

 

  • buy a product,
  • copy the code to the gift card field in the cart and submit it,
  • the gift card value is rendered in the orders list
  • complete the order
  • reciept in browser shows used gift cards
  • reciept in email doesn't show used gift cards <--- Correct?

/Merethe

EDIT: Added screenshot.

gift.jpg
 
Christian Hansen Nørgaard
Reply
Original message by Merethe VrÃ¥ Andersen posted on 6/6/2017 2:04:17 PM:

These steps are working?

  • buy a gift card and complete the order - Yes
  • reciept in browser shows gift card code (the bought gift card appers in the gift cards list in the backend), - Yes
  • email shows the code too - No

 

  • buy a product, - Yes
  • copy the code to the gift card field in the cart and submit it, - Yes
  • the gift card value is rendered in the orders list - Yes
  • complete the order - Yes
  • reciept in browser shows used gift cards - Yes
  • reciept in email doesn't show used gift cards <--- Correct? Correct and also no code, no expire date, etc.

/Merethe

So I am facing the issue of getting codes for all emails.

 
Merethe Vrå Andersen Dynamicweb Employee
Merethe Vrå Andersen
Reply

And you use the templates, that I attached earlier? (btw... what version do you use?)

Showcart
Reciept
Wraporderemail

These templates, that I attached earlier, are the Wrap templates (dw9) that I use at my test solution.

/Merethe

 

 
Christian Hansen Nørgaard
Reply

I am using version 8.9.1.12 and I've used the same code as in your templates. But I'll have a look at it today with a DW developer.

 

You must be logged in to post in the forum