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.

  • Zac 223 posts 575 karma points
    Aug 15, 2011 @ 17:01
    Zac
    0

    Issue with custom shipping methods since upgrading to UCommerce 2

    Hi again, sorry to post yet another question about this upgrade of ours from 1.5 to 2.

    Since the upgrade, I've been having some strange issues with the custom shipping costs.

    Here's an example of when a problem is hit:

    1. Put item(s) in cart
    2. Go to checkout
    3. Put in address
    4. Choose a shipping method (Standard or Premier, shippingMethodId 9 and 10 respectively)

    Now, this is where it's getting strange. I've had the UpdateShipping xslt print out values:

    <xsl:if test="string-length($shippingMethodId) > 0">
    <xsl:variable name="result" select="CommerceLibrary:CreateShipment($shippingMethodId, 'Shipment', true())"></xsl:variable>
    <xsl:variable name="pipelineResult" select="CommerceLibrary:ExecuteBasketPipeline()"/>
    <xsl:copy-of select="$pipelineResult"></xsl:copy-of>
    <xsl:copy-of select="$shippingMethodId"></xsl:copy-of>
    </xsl:if>

    I'm referencing that XSLT macro from the top of my order confirmation page, before I run our version of PageDetails, which also shows the shipping cost name and price. As I'm printing out a copy of the pipeline result and method id, I'm getting:

    The pipeline executed succesfully.10

    Which is great. I chose Premier (10), and it ran successfully.

    However, here is an "<xsl:copy-of" showing the contents of the purchase order at this point. Note how it's showing the wrong shipping method (9), but the correct shipping method name:

    <purchaseOrder ... status="Basket" createdDate="15/08/2011 15:31:01" ...>
    <discounts />
    <orderProperties />
    <lineItems>
    <lineItem index="0" ...>
    <orderProperties />
    <discounts />
    </lineItem>
    </lineItems>
    <shipments>
    <shipment index="0" shipmentId="861" name="Premier Delivery" ...
    price="3.95" shippingMethodId="9" ...>
    <address addressId="2244" .../>
    </shipment>
    </shipments>
    <payments />
    <addresses />
    <billingAddress><address ... /></billingAddress>
    </purchaseOrder>

    When I go through to sagepay, it also has the incorrect order total

    Any ideas on this one?

    Thanks!

    Zac

  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 16, 2011 @ 15:59
    Søren Spelling Lund
    0

    Hi Zac,

    Which version of uCommerce 2 are you running?

  • Zac 223 posts 575 karma points
    Aug 17, 2011 @ 15:19
    Zac
    0

    Hi Søren,

    version 2.0.1.0

  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 23, 2011 @ 19:33
    Søren Spelling Lund
    0

    Hi Zac,

    I had to do a little digging to find the issue. Turns out there was a bug in uCommerce which caused it to keep the old id around until a subsequent request. I fixed it and release uCommerce 2.0.4.0 for you. Please download it and let me know how you get on with it.

    Regarding the other issue with the wrong total I'm going to need some more information before I can figure out what's going on.

    Could you include the full order XML and let me know which values are wrong, what you expected them to be, and what your shipping method/VAT config is for the methods in play?

    Thanks.

  • Zac 223 posts 575 karma points
    Aug 24, 2011 @ 10:45
    Zac
    0

    Many thanks Søren.

    I've had a go with this version (overwrote all the DLL files). Now I have the correct shipping id (before only the correct shipping name was coming up), but the price still seems to be wrong:

    <shipment index="0" shipmentId="860" name="Premier Delivery" 
    createdDate="24/08/2011 09:19:00" shippingMethodId="10"
    deliveryNote="" trackAndTrace="" price="3.95" taxRate="0.00"
    tax="0.00" shipmentTotal="3.95">

    The price should be £6.95. If I refresh the page (and re-post), it will then be correct, and the correct total will be there too.

    When I said the incorrect order total going through to SagePay, I meant the total was incorrect because it had the wrong shipping charge (so, the same issue, there's no other issue with the total as far as I know!).

    Cheers,

    Zac

  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 24, 2011 @ 16:36
    Søren Spelling Lund
    0

    Hi Zac,

    Are you executing the basket pipeline before you make a call to GetBasket()?

  • Zac 223 posts 575 karma points
    Aug 24, 2011 @ 17:12
    Zac
    0

    Well, I'm doing that in the UpdateShipping xslt template which gets called before the basket one. So yes...

    However...

    I'm not calling GetBasket in what you'd call the order details page, I'm using CommerceLibrary:GetPurchaseOrder:

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

    Perhaps this explains the difference? The purchase order isn't getting updated anymore, even if the basket is?

    The reason we're using the orderGuid? If memory serves, because it's the same template that the user sees when the come back from SagePay and by then the basket is empty.

    Cheers,

    Zac

  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 26, 2011 @ 18:01
    Søren Spelling Lund
    0

    The two APIs will produce the same XML structure so that's not it.

    Is there a way I can take a look at the XSLT itself?

  • Zac 223 posts 575 karma points
    Aug 26, 2011 @ 18:10
    Zac
    0

    Certainly:

    <?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"
    xmlns:Business="urn:Business"
    exclude-result-prefixes="msxml umbraco.library CommerceLibrary Business">

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

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

    <xsl:template match="/">
    <style type="text/css">
    p { padding:8px 0;}
    </style>
    debug: <textarea><xsl:copy-of select="$cart"/></textarea>
    <xsl:apply-templates select="$cart/purchaseOrder"></xsl:apply-templates>
    </xsl:template>

    <xsl:template match="purchaseOrder">
    <xsl:if test="@orderNumber != ''">
    <p>
    Order reference number: <strong>
    <xsl:value-of select="@orderNumber"/>
    </strong>
    </p>
    </xsl:if>
    <p>
    <strong>Customer</strong>
    </p>
    <xsl:apply-templates select="billingAddress/address"/>
    <xsl:for-each select="shipments/shipment">

    <p>
    <strong>
    <xsl:variable name="surcharge" select="Business:GetSurcharge(address/@postalCode)"/>
    Shipping with <xsl:value-of select="@name"/>: £<xsl:value-of select="format-number(@price - $surcharge,'0.00')"/>
    <xsl:if test="$surcharge &gt; 0">
    (plus £<xsl:value-of select="format-number($surcharge,'0.00')"/>&nbsp;<a href="/delivery-information">regional delivery surcharge</a>)
    </xsl:if>
    </strong>
    </p>
    <xsl:apply-templates select="address"/>
    </xsl:for-each>
    <p>
    <strong>Special Delivery Instructions:</strong>&nbsp;<xsl:value-of select="$cart/purchaseOrder/billingAddress/address/@attention"/>
    </p>
    <p>
    <strong>Order Summary</strong>
    </p>
    <xsl:call-template name="lineItems"></xsl:call-template>
    </xsl:template>

    <xsl:template name="lineItems">
    <table class="basket">
    <thead>
    <tr>
    <td class="item">Item no.</td>
    <td class="desc">Description</td>
    <td class="price">Item price</td>
    <td class="vat">VAT</td>
    <td class="quant">Quantity</td>
    <td class="total">Total (inc VAT)</td>
    </tr>
    </thead>
    <tbody>
    <xsl:for-each select="$cart/purchaseOrder/lineItems/lineItem">
    <tr>
    <td class="item">
    <xsl:value-of select="@sku"/>
    </td>
    <td class="desc">
    <xsl:value-of select="@productName"/>
    </td>
    <td class="price">
    £<xsl:value-of select="CommerceLibrary:FormatCurrency(@price)"/>
    </td>
    <td class="vat">
    £<xsl:value-of select="CommerceLibrary:FormatCurrency(@price * @vatRate)"/>
    </td>
    <td class="quant">
    <xsl:value-of select="@quantity"/>
    </td>
    <td class="total">
    <xsl:choose>
    <xsl:when test="@unitDiscount != 0">
    <xsl:variable name="discountVat" select="(@price + (@price * @vatRate)) - @total"></xsl:variable>
    <span style="text-decoration:line-through">
    £<xsl:value-of select="CommerceLibrary:FormatCurrency(@total + $discountVat)"/>
    </span>&nbsp;
    £<xsl:value-of select="CommerceLibrary:FormatCurrency(@total)"/>
    </xsl:when>
    <xsl:otherwise>
    £<xsl:value-of select="CommerceLibrary:FormatCurrency(@total)"/>
    </xsl:otherwise>
    </xsl:choose>
    </td>
    </tr>
    <xsl:call-template name="discountTemplate">
    <xsl:with-param name="discounts" select="discounts"/>
    <xsl:with-param name="id" select="@index"/>
    <xsl:with-param name="vatRate" select="@vatRate"/>
    </xsl:call-template>

    </xsl:for-each>
    <tr>
    <td colspan="5">Sub total:</td>
    <td>
    £<xsl:value-of select="CommerceLibrary:FormatCurrency(@subTotal + @vat)"/>
    </td>
    </tr>
    </tbody>
    <tfoot>
    <tr>
    <td colspan="5">Order total with delivery:</td>
    <td>
    £<xsl:value-of select="CommerceLibrary:FormatCurrency(@orderTotal)"/>
    </td>
    </tr>
    </tfoot>
    </table>
    </xsl:template>

    <xsl:template match="address">
    <p>
    Name: <xsl:value-of select="@firstName"/>&nbsp;<xsl:value-of select="@lastName"/><br/>
    <xsl:if test="@company != ''">
    Company: <xsl:value-of select="@company"/>
    <br/>
    </xsl:if>
    <xsl:value-of select="@line1"/><br/>
    <xsl:if test="@line2 != ''">
    <xsl:value-of select="@line2"/>
    <br/>
    </xsl:if>
    <xsl:value-of select="@city"/><br/>
    <xsl:value-of select="@postalCode"/><br/>
    <xsl:value-of select="@country"/>
    <xsl:if test="@emailAddress != ''">
    <br/>E-mail: <xsl:value-of select="@emailAddress"/>
    </xsl:if>
    </p>
    </xsl:template>

    <xsl:template name="discountTemplate">
    <xsl:param name="discounts" />
    <xsl:param name="id" />
    <xsl:param name="vatRate" />
    <xsl:if test="count($discounts/discount) > 0">
    <xsl:for-each select="$discounts/discount">
    <tr>
    <xsl:attribute name="class">
    discount_<xsl:value-of select="$id" />
    </xsl:attribute>
    <td></td>
    <td class="note" colspan="4">
    <xsl:value-of select="@campaignName"/> - <xsl:value-of select="@campaignItemName"/>
    </td>
    <td class="total">
    -£<xsl:value-of select="format-number( @amountOff + (@amountOff * $vatRate),'0.00')"/>
    </td>
    </tr>
    </xsl:for-each>
    </xsl:if>
    </xsl:template>

    </xsl:stylesheet>
  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 26, 2011 @ 18:30
    Søren Spelling Lund
    0

    Just for the hell of it: Could you try and put in a call to CommerceLibrary:ExecuteBasketPipeline() just before you do GetBasket/GetPurchaseOrder in that macro?

  • Zac 223 posts 575 karma points
    Aug 26, 2011 @ 18:36
    Zac
    0

    I'd actually already given that a go, but I just tried it again since updating the version, still no luck.

    For the record, I only replaced the .DLL files from the new version of uCommerce, I didn't update anything else. Hope that's not part of the problem?

  • Zac 223 posts 575 karma points
    Aug 26, 2011 @ 18:36
    Zac
    0

    Sorry, weird XSLT error double post. Damn Our Umbraco!

  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 29, 2011 @ 10:47
    Søren Spelling Lund
    0

    Hi Zac,

    Would it be possible to take a look at the site directly? If you could send me a copy of your website and database, I'd be happy to try and dig through it to repro the issue you're seeing.

    Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft