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.

  • Ncik 10 posts 30 karma points
    May 23, 2011 @ 06:59
    Ncik
    0

    send email when ordering

    i'm trying to access the order/customer info from the email template so i can have a summary of what's been ordered included in the email, and the email can be personalised. pretty standard stuff i would think.but there are no examples on the net that i can find.

    i'm seeing the order guid in the Request object querystring but finding order guid in the DB is proving difficult. where is it? how can i use the guid to retrieve the order details?

    i've read this http://www.publicvoid.dk/SendingEmailUsingUCommerce.aspx but i can't workout from that post how to pass the customerid thru in the query string ffrom my submitbasket.xslt.

    here's my xslt

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library"
     xmlns:CommerceLibrary="urn:CommerceLibrary"
     exclude-result-prefixes="msxml umbraco.library CommerceLibrary">
      <xsl:output method="xml" omit-xml-declaration="yes"/>
      <xsl:param name="currentPage"/>
      <xsl:template match="/">
        <SCRIPT language="JavaScript">
          <![CDATA[            
                
                function redirectShoppingCart()
                {
                    var val="../bp-shop.aspx";   
                    location.href =val;
                }    
                 
                ]]>
        </SCRIPT>
        <xsl:variable name="isPostback" select="umbraco.library:RequestForm('submitBasket') "></xsl:variable>
        <xsl:if test="string-length($isPostback) > 0">
          
          <!--<xsl:variable name="result" select="CommerceLibrary:ExecuteBasketPipeline()"/>-->
          <xsl:value-of select="CommerceLibrary:ExecuteBasketPipeline()"></xsl:value-of>
        
          <xsl:variable name="orderGuid" select="CommerceLibrary:GetBasket()/purchaseOrder/@orderGuid"/>
          <xsl:value-of select="$orderGuid"/>
          <xsl:variable name="result2" select="CommerceLibrary:SendEmail('OrderConfirmation', $orderGuid)"/>
          <xsl:value-of select="$result2"/>
          
          <!---->      
          <!--<xsl:variable name="addressResult" select="CommerceLibrary:Set('Billing')"></xsl:variable>-->
          <xsl:variable name="result1" select="CommerceLibrary:Checkout()"></xsl:variable>
          
          <div id="continue_container">
            <div class="continue_container_r">
              <div class="btn_AddToCart">
                <input  type="submit" value="Continue" id="btnContinue" class="btn_UpdateCart"
                        onclick="redirectShoppingCart();"></input>
              </div>
            </div>
            <div class="continue_container_l">
              <h3> Your order has been placed successfully</h3>
              
            </div>
          </div>
    
        </xsl:if>
      </xsl:template>
    </xsl:stylesheet>
  • Søren Spelling Lund 1797 posts 2786 karma points
    May 23, 2011 @ 10:21
    Søren Spelling Lund
    0

    The easiest way to send an order confirmation is to use the SendEmail task in the checkout pipeline (preconfigured when you install uCommerce). It will look for an e-mail type called OrderConfirmation.

    In the template you set up for OrderConfirmation you can use GetPurchaseOrder:

    CommerceLibrary:GetPurchaseOrder($orderGuid)

    to load the order information.

    The reason you have to use this one instead of GetBasket() is that the basket is gone once Checkout is called beucase it's converted to a new order.

    Hope this helps.

  • Ncik 10 posts 30 karma points
    May 24, 2011 @ 03:53
    Ncik
    0

    if anyones interested in how i did this in a bit more detail. maybe it's wrong, but i works.

    here's some of the code behind of my email template where i grab the order guid from the query string that gets sent by default from SubmitBasket.xslt.

    public partial class Email : System.Web.UI.MasterPage
        {
            protected void Page_Load(object sender, EventArgs e)
            {                    
                var custname = Request.QueryString["orderNumber"].ToString();
                Guid orderGuid = new Guid("3d8c28dc-2ca2-41d6-a5da-40843e980bee");
    
                var orderObj = UCommerce.EntitiesV2.PurchaseOrder.Find(x => x.OrderGuid == orderGuid);
    
                var peep = orderObj.Select(x => x.Customer);
    
                var fname = peep.FirstOrDefault().FirstName;
              
                litName.Text = fname.ToString();        
            }
        }
  • Ncik 10 posts 30 karma points
    May 24, 2011 @ 03:57
    Ncik
    0

    here's the xslt. i commented out the send email task in the checkout pipline config and send the email from the xslt. hope this helps someone

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
     <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library"
     xmlns:CommerceLibrary="urn:CommerceLibrary"
     exclude-result-prefixes="msxml umbraco.library CommerceLibrary">
     <xsl:output method="xml" omit-xml-declaration="yes"/>
     <xsl:param name="currentPage"/>
     <xsl:template match="/">
         <SCRIPT language="JavaScript">
             <![CDATA[            
                         
                         function redirectShoppingCart()
                         {
                                 var val="../bp-shop.aspx";   
                                 location.href =val;
                         }    
                          
                         ]]>
         </SCRIPT>
         <xsl:variable name="isPostback" select="umbraco.library:RequestForm('submitBasket') "></xsl:variable>
         <xsl:if test="string-length($isPostback) > 0">        
         
             <xsl:value-of select="CommerceLibrary:ExecuteBasketPipeline()"></xsl:value-of>
             <!-- The query string param will always be 'orderNumber', but might contain something else like a customer number or product id -->
             <xsl:variable name="orderGuid" select="CommerceLibrary:GetBasket()/purchaseOrder/@orderGuid"/>
             <!--<xsl:variable name="orderGuid" select="umbraco.library:RequestQueryString('orderNumber')"/>-->
             <xsl:variable name="cart" select="CommerceLibrary:GetPurchaseOrder($orderGuid)"/>                      
                         
             <xsl:variable name="result2" select="CommerceLibrary:SendEmail('OrderConfirmation', $orderGuid)"/>
             <xsl:value-of select="$result2"/>
                         
             <xsl:variable name="result1" select="CommerceLibrary:Checkout()"></xsl:variable>
             
             <div id="continue_container">
                 <div class="continue_container_r">
                     <div class="btn_AddToCart">
                         <input  type="submit" value="Continue" id="btnContinue" class="btn_UpdateCart"
                                         onclick="redirectShoppingCart();"></input>
                     </div>
                 </div>
                 <div class="continue_container_l">
                     <h3> Your order has been placed successfully</h3>
             
                 </div>
             </div>
    
         </xsl:if>
    
      
     </xsl:template>
      
    </xsl:stylesheet>
  • Søren Spelling Lund 1797 posts 2786 karma points
    May 25, 2011 @ 10:39
    Søren Spelling Lund
    0

    There's no right and wrong. Just getting the job done :) In fact this is the way we originally did it in the store, but the behavior was changed to avoid some page requests in the checkout flow and duplicate e-mails being sent if the order confirmation page is displayed multiple times.

    The pipeline ensures that the confirmation is only sent once as it's executed only when the order is placed.

Please Sign in or register to post replies

Write your reply to:

Draft