Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Mr A 216 posts 278 karma points
    May 31, 2012 @ 13:26
    Mr A
    0

    How to set email fields in order confirmation email

    Hi , I am using the latest version of ucommerce , where email is set using checkout pipeline , email uses email template which is empty during the initial installation , what i need to know how can i pass the invoice details to confirmation email , i tried writing a macro in the email template using your code :

    var purchaseOrder = SiteContext.Current.OrderContext.GetBasket().PurchaseOrder;
    var email = purchaseOrder.GetBillingAddress().EmailAddress

    , but the order confirmation email which i received contains an error , cannot load razor.

    Any ideas on how to send the detail order confirmation email.

    Also i am using paypal for payments.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 01, 2012 @ 14:15
  • Mr A 216 posts 278 karma points
    Jun 01, 2012 @ 14:18
    Mr A
    0

    I tried the razor scripts and use that macro inside the email template but it comes up with error loading script , i have posted another question on the support forum, tried all other methods with no success, I know that it uses a checkout pipeline to send email automatically , but i just cant pass the variables in that email using razor maro script.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 01, 2012 @ 14:51
    Søren Spelling Lund
    0

    There are probably compile errors in your script. Fire up a debugger to get better error messages.

  • Thomas Foskey 15 posts 35 karma points
    Jun 02, 2012 @ 05:26
    Thomas Foskey
    0

    Soren,

    First of all, thank you very much for creating such an awesome tool for the community.  I wanted to see if I could pick your brain for an unusual issue I'm seeing while also attempting to get the email confirmation with the order details working.  I have poured through your documentation (via the link you posted above) on getting email working but I still can't seem to get the order details to pull into the body of the email.  It sends the email just fine - just no order details.

    I have been able to prove that the macro is firing and I can even see where the values are pulling correctly as I have them writing to the page right after the pipeline executes successfully.  Even though they appear on the page, I'm getting blank values in the email and both the page and the email are using the same macro.  Also, you mention a QueryString parameter of "orderNumber" which I never get a value for when I get to the page that displays the order details. I'm guessing this has something to do with it, but I'm not sure how to resolve it. 

    Instead, I'm having to pass it manually when I go to submit the order from the previous page using a custom parameter I call "oid".  Sample partial URL:  checkout/orderconfirmation.aspx?oid=8f7a1b1f-9d93-4eb4-b9c8-b287712f03cc. 

    Also, I'm not using razor, as I'm still on a previous version of Umbraco that doesn't support it.  Not quite ready for razor yet :)

    Any ideas would be greatly appreciated!

  • Thomas Foskey 15 posts 35 karma points
    Jun 02, 2012 @ 05:49
    Thomas Foskey
    0

    Ok, now the plot thickens.  It DOES return a value for the order number using the Request.QueryString('orderNumber') ONLY in the email.  But get this, it's duplicated!

    So my value for the order number is:  940d587b-5764-4c7d-88df-f0f84ca34010,940d587b-5764-4c7d-88df-f0f84ca34010

    Instead of just this: 940d587b-5764-4c7d-88df-f0f84ca34010

    I wonder why it's duplicating like this?  With it trying to pull the purchase order with GetPurchaseOrder using an duplicated order number, it's not going to get anything back.  This would certainly be causing my "empty" values.

  • Thomas Foskey 15 posts 35 karma points
    Jun 02, 2012 @ 06:15
    Thomas Foskey
    0

    Well, those duplicated order numbers were definitely the culprit.  As an experiment, I decided the split them up and grab the first instance and viola!  It worked!  Still have no clue as to why they're being duplicated, but at least I have a workaround now.

  • Mr A 216 posts 278 karma points
    Jun 06, 2012 @ 10:55
    Mr A
    0

    @Thomas Foskey , I cant still workout the email , i can get the order number send through email using :

    <xsl:variable name="orderGuid" select="umbraco.library:RequestQueryString('orderNumber')"/> 

    but i cant get the order details and billing address in the email , Is it possible if you can send me the xslt you are using for orderconfirmation email.

    Thanks

  • Mr A 216 posts 278 karma points
    Jun 06, 2012 @ 11:29
    Mr A
    0

    I tried this :

     <xsl:variable name="orderGuid" select="umbraco.library:RequestQueryString('orderNumber')"/> 
     <xsl:variable name="cart" select="CommerceLibrary:GetPurchaseOrder($orderGuid)"/>

      <table>
          <tr>
            <td>
               <xsl:value-of select="$orderGuid"/>
            <td>
       
          
            <td>

              <xsl:value-of select"$cart/@OrderTotal" />
              
            td>
            <td>
              <xsl:value-of select"$cart/@SubTotal" />
              
            td>
           
          tr>
        table>

     

    But in the order confirmation email i am just getting the orderguid ,

    not the order total and subtotal :( , any ideas where i am getting it wrong ,

    i checked the database with the orderid, its not duplicated.

  • Thomas Foskey 15 posts 35 karma points
    Jun 07, 2012 @ 06:08
    Thomas Foskey
    0

    Hi Mr. A,

    I did an implementation where I could share the same xslt to display the confirmation information on the page AND send the SAME info via email.  Since my orderNumber was being duplicated (not sure why), I had to split it out by "," (see below with the substring-before line).  The top RequestQueryString('orderNumber') is the parameter that uCommerce uses for the email functionality. If it doesn't find anything, it assumes it's displaying the confirmation page on MY site and gets it from the RequestQueryString('orderGuid'). 

    Below is my xsl.

    Hope it helps!

      <xsl:output method="xml" omit-xml-declaration="yes"/>

      <xsl:param name="currentPage"/>
      <xsl:variable name="orderNumber" select="umbraco.library:RequestQueryString('orderNumber')"/>
       
      <!--GET ORDER NUMBER -->
      <xsl:variable name="oid">
        <xsl:choose>
          <xsl:when test="contains($orderNumber, ',')">
            <xsl:value-of select="substring-before($orderNumber, ',')" />
          </xsl:when>
          <xsl:when test="$orderNumber = ''">
            <xsl:value-of select="umbraco.library:RequestQueryString('orderGuid')" />
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$orderNumber" />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
        
      <xsl:template match="/">    
        <!--GET PURCHASE ORDER -->
        <xsl:variable name="basket" select="CommerceLibrary:GetPurchaseOrder($oid)"/>
        <p><b>Confirmation# <xsl:value-of select="$oid" /></b></p>
        <xsl:apply-templates select="$basket/purchaseOrder"></xsl:apply-templates>    
      </xsl:template>

      <xsl:template match="purchaseOrder">
        <h5>Customer Information</h5>
        <xsl:apply-templates select="billingAddress/address"/>
        
        <h5>Shipping Information</h5>
        <div>      
          <xsl:for-each select="shipments/shipment">
              <div>
                <xsl:value-of select="@name"/><xsl:value-of select="CommerceLibrary:FormatCurrency(@price)" /> <br />
                <xsl:apply-templates select="address" />
              </div>
          </xsl:for-each>      
        </div>
        
        <h5>Order Details</h5>
        <div>
          <table>
            <tr>
              <th></th>
              <th>Item no.</th>
              <th>Description</th>
              <th>Item price</th>
              <th>Quantity</th>
              <th>Total</th>
            </tr>
            <xsl:call-template name="lineItems"></xsl:call-template>
          </table>
        </div>
      </xsl:template>

      <xsl:template name="lineItems">
        <xsl:for-each select="lineItems/lineItem">
          <tr>
            <td>
              <span style="cursor:pointer;" class="toggleDiscount">
                <xsl:attribute name="toggleid">discount_<xsl:value-of select="@index" /></xsl:attribute>
                <img src="../../Umbraco/UCommerce/Images/expand.png" alt="Show discounts" title="Show discounts" />
              </span>
            </td>
            <td>
              <xsl:value-of select="@sku"/>
            </td>
            <td>
              <xsl:value-of select="@productName"/>
            </td>
            <td>
              <xsl:choose>
                <xsl:when test="@unitDiscount != 0">
                  <span style="text-decoration:line-through">
                    <xsl:value-of select="CommerceLibrary:FormatCurrency(@price)"/>
                  </span>&nbsp;
                  <xsl:value-of select="CommerceLibrary:FormatCurrency(@price - @unitDiscount)"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="CommerceLibrary:FormatCurrency(@price)"/>
                </xsl:otherwise>
              </xsl:choose>
            </td>
            <td>
              <xsl:value-of select="@quantity"/>
            </td>
            <td>
              <xsl:value-of select="CommerceLibrary:FormatCurrency(@total)"/>
            </td>
          </tr>
          <tr>
            <td></td>
            <td colspan="5">
              <xsl:call-template name="discountTemplate">
                <xsl:with-param name="discounts" select="discounts"/>
                <xsl:with-param name="id" select="@index"/>
              </xsl:call-template>
            </td>
          </tr>
        </xsl:for-each>        
        <tr>
          <td></td>
          <td colspan="4">Sub total:</td>
          <td>
            <xsl:value-of select="CommerceLibrary:FormatCurrency(@subTotal)"/>
          </td>
        </tr>
        <tr>
          <td>
            &nbsp;
          </td>
          <td colspan="4">Order discounts:</td>
          <td>
            -<xsl:value-of select="CommerceLibrary:FormatCurrency(@discount)"/>
          </td>
        </tr>
        <tr>
          <td></td>
          <td colspan="5">
            <xsl:call-template name="discountTemplate">
              <xsl:with-param name="discounts" select="discounts"/>
              <xsl:with-param name="id" select="@orderGuid"/>
            </xsl:call-template>
          </td>
        </tr>
        <tr>
          <td></td>
          <td colspan="4">Order total:</td>
          <td>
            <xsl:value-of select="CommerceLibrary:FormatCurrency(@orderTotal)"/>
          </td>
        </tr>
      </xsl:template>
        
      <xsl:template match="address">
        <div>
          <xsl:value-of select="@firstName"/>&nbsp;<xsl:value-of select="@lastName"/>
        </div>
        <div>
          <xsl:value-of select="@line1"/>
        </div>
        <div>
          <xsl:value-of select="line2"/>
        </div>
        <div>
          <xsl:value-of select="@city"/>,&nbsp;<xsl:value-of select="@state" />&nbsp;
          <xsl:value-of select="@postalCode"/>
        </div>
        <div>
          E-mail:
          <xsl:value-of select="@emailAddress"/>
        </div>
      </xsl:template>

      <xsl:template name="discountTemplate">
        <xsl:param name="discounts" />
        <xsl:param name="id" />

        <xsl:if test="count($discounts/discount) > 0">
          <div style="width:100%; display:none;">
            <xsl:attribute name="id">discount_<xsl:value-of select="$id" /></xsl:attribute>
            <table cellpadding="0" cellspacing="0" style="width:100%;">
              <xsl:for-each select="$discounts/discount">
                <tr style="background-color:#eeeeee">
                  <td></td>
                  <td colspan="6" style="padding-left:20px;">
                    <xsl:value-of select="@campaignName"/> <xsl:value-of select="@campaignItemName"/> <xsl:value-of select="@description"/>
                  </td>
                </tr>
              </xsl:for-each>
            </table>
          </div>
        </xsl:if>
      </xsl:template>

  • Mr A 216 posts 278 karma points
    Jun 07, 2012 @ 10:54
    Mr A
    0

    Thanks @Thomas , though mine was not duplicating , its working now , i just need to no , as i have no prior knowledge of XSLT , is it case sensitive , coz when i try @ProductName   it doesnt works but @productName works , and in the database there is a column with ProductName in Products table , i am just confused how , the system is working, thanks


  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 18, 2012 @ 13:37
    Søren Spelling Lund
    0

    XSLT is case sensitive.

  • Shuchita 45 posts 154 karma points
    Aug 06, 2013 @ 04:10
    Shuchita
    0

    I am trying to achieve the same with razor. I am able to display Sku, Product Name, Price, Quantity and Total.

    But how to get ShippingPrice, SubTotal and OrderTotal?

    Also, I need help in showing shipping address details with razor ?

    Any help would be much appreciated!

  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 16, 2013 @ 10:30
    Søren Spelling Lund
    0

    Hi Shuchita,

    If you install the Razor store and check out the Preview template you'll have examples of how to query the order and display the relevant information.

    You have to change one thing: The way the order is loaded. The Preview macro will use TransactionLibrary.GetBasket(), which will not your in your scenario as the basket is converted to an order.

    Rather than doing that you can load the order based on orderGuid provided in the querystring for the configured template like so:

    @{
    Guid orderGuid = new Guid(Request.QueryString["orderGuid"]);
    var order = PurchaseOrder.SingleOrDefault(x => x.OrderGuid == orderGuid);

    // from here you can use the same code found in Preview.cshtml to display order, orderline, and shipping info
    }

    Hope this helps.

Please Sign in or register to post replies

Write your reply to:

Draft