Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 26 Jan 2023 01:09 AM by  Steve L
Help with Send Email Action in Product Variant
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Michael Tyson



New Member


Posts:42
New Member


--
20 Jan 2023 01:45 AM

    We need to send an email as an Action in a product variant.

    Below is the std template code. Note an email address is entered as part of the mailto code in the template.

    We need this email to vary based on the customer placing the order.

    Can anyone help with this. What code do we enter to acheive this?

    <xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <out>
          <sendMail>
            <mailFrom>support@company.com</mailFrom>
            <mailTo>johndoe@example.com</mailTo>
            <subject>Email subject</subject>
            <textBody>Email text body</textBody>
            <htmlBody>
              <h1>Email HTML body</h1>
            </htmlBody>
          </sendMail>
        </out>
      </xsl:template>
    </xsl:transform>

    0

    Steve L



    Veteran Member


    Posts:2890
    Veteran Member


    --
    20 Jan 2023 02:40 PM

    You need to use the IF or CHOOSE condition.

    <xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <out>
          <sendMail>
            <mailFrom>support@company.com</mailFrom>
            <mailTo>johndoe@example.com</mailTo>
            <subject>Email subject</subject>
            <textBody>Email text body</textBody>
            <htmlBody>
              <xsl:choose>
                <xsl:when test="/in/user/email = 'john@somewhere.com'" >
                    <h1>First email HTML body</h1>
                </xsl:when>
                <xsl:when test="/in/user/email = 'john@other.com'" >
                    <h1>Second email HTML body</h1>
                </xsl:when>
                <xsl:otherwise>
                     <h1>Default email HTML body</h1>
                </xsl:otherwise>
            </xsl:choose>

            </htmlBody>
          </sendMail>
        </out>
      </xsl:template>
    </xsl:transform>

     

    I hope this helps! smiley

    0

    Michael Tyson



    New Member


    Posts:42
    New Member


    --
    20 Jan 2023 10:30 PM

    Thank you for your help. Its not really what we need.

    We do not want to define the email address in the action. We want the action to use the email address on the order in progress and send the email to the order email address. Preferrabley the Shipping Email address

    0

    Steve L



    Veteran Member


    Posts:2890
    Veteran Member


    --
    26 Jan 2023 01:09 AM

    For the mailTo, just specify the user's email like this so it sets it to the email address of the user.

    <mailTo><xsl:value-of select="/in/user/email" /></mailTo>

    0
    You are not authorized to post a reply.