Is there a way to send a shopping cart "manually" in MVC by a CTA

Dominic Boyer asked on November 26, 2020 20:55

I was wondering if it possible via a CTA in MVC "send shopping cart" a way to send a full shopping to a customer in a email notification or maybe just a notification with a url that include the cartID. I can probably can do this last one with the .SendEmailAsync API...

Recent Answers

Arjan van Hugten answered on November 27, 2020 14:31 (last edited on November 27, 2020 14:32)

We use the "EmailSender" from Kentico to send emails from the MVC site. You can then use a Kentico email template's with macro's in it. There is a macro for retrieving the current shopping cart ({% ECommerceContext.CurrentShoppingCart %}), but I'm not sure if that is working directly in the email template.


public static void SendMail(string templateName, string recipient, MacroResolver resolver = null)
    var email = new EmailMessage();
    var template = EmailTemplateProvider.GetEmailTemplate(templateName, SiteContext.CurrentSiteID);

    if (resolver == null)
        resolver = MacroResolver.GetInstance();

    email.EmailFormat = EmailFormatEnum.Both;
    email.From = template.TemplateFrom;
    email.Recipients = recipient;
    email.Subject = template.TemplateSubject;

    EmailSender.SendEmailWithTemplateText(SiteContext.CurrentSiteName, email, template, resolver, false);

You could also try adding the shopping cart as custom macro resolver data. Like this:

macroResolver.SetNamedSourceData("ShoppingCart", shoppingCart);

Which can be used in the email template:

{% ShoppingCart.ID %}

0 votesVote for this answer Mark as a Correct answer

Dominic Boyer answered on November 27, 2020 14:49

Hi Arjan van Hugten thank you for your response, i will try to implement this. Have a nice day

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.