You might have an empty basket assigned to you. A new basket will be assigned to the customer if a call is made to CommerceLibrary:GetBasket() as it will create a new basket if one is not present. If you want to control when baskets are created you can use GetBasket(false), which tells uCommerce not to assign a new basket if one isn't assigned to the customer.
Empty Cart
I have installed ucommerce and customising it within umbraco. I know I can remove an item from cart, if I ste its qty to 0 and update it.
Is there a way that by calling a simple macro or function I empty the cart no matter how many products are in there?
Nauman
I found the solution
<xsl:template name="emptyBasketTemplate">
<xsl:if test="CommerceLibrary:HasBasket()">
<xsl:for-each select="CommerceLibrary:GetBasket()/purchaseOrder/lineItems/lineItem">
<!-- Find the name of the posted quantity change -->
<xsl:variable name="postedQuantity" select="umbraco.library:RequestForm(concat('quantityInput_', @index))"/>
<xsl:variable name="result" select="CommerceLibrary:UpdateLineItem(@index, 0)"></xsl:variable>
</xsl:for-each>
</xsl:if>
</xsl:template>
I have amended following line
<xsl:variable name="result" select="CommerceLibrary:UpdateLineItem(@index, 0)"></xsl:variable>
now i call this template thorugh a macro to empty the cart
CommerceLibrary:ClearBasket() should do the trick as well.
Thanks Soren for the help.
Cheers
Nauman
Why does uCommerce:HasBasket() return 'true' even if there are no items in the basket?
Hi Tony,
You might have an empty basket assigned to you. A new basket will be assigned to the customer if a call is made to CommerceLibrary:GetBasket() as it will create a new basket if one is not present. If you want to control when baskets are created you can use GetBasket(false), which tells uCommerce not to assign a new basket if one isn't assigned to the customer.
Hope this helps.
is working on a reply...