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.

  • PBE 1 post 21 karma points
    Apr 22, 2011 @ 17:32
    PBE
    0

    Redirecting to Cart after add

    Using the base store install as a foundation, is there a good way to have the site redirect the user to the cart page after the add to cart button has been clicked on the product page?  

    Feel I am missing something easy here!

    Thanks.

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

    Hi Jason,

    The easiest way to do it is to add the redirect code to your add to cart macro. If you're using the uCommerce Store it's found in the AddToCart[XSLT].xslt file. Add the end of the macro add the following call and you're good:

    Here's a post on how to do the redirect in Umbraco.

    Had hoped for a umbraco.library:redirect, but that doesn't exist unfortunately.

  • Zac 223 posts 575 karma points
    May 05, 2011 @ 16:48
    Zac
    0

    I did this by changing the forum on the poduct page to post to the basket page, and added a few parameters as hidden inputs. I also sent along a return url (so that on the basket page you can return to the page you were viewing with a "Continue Shopping" button. This is the form in the product XSLT:

    <form method="post" action="/shop/checkout/basket">
        <input type="hidden" name="sku">
            <xsl:attribute name="value">
                <xsl:value-of select="$product/product/@sku"/>
            </xsl:attribute>
    </input>
    <input type="hidden" name="catalog"> <xsl:attribute name="value">
    <xsl:value-of select="$catalogName"/> </xsl:attribute> </input> <input type="hidden" name="returnUrl"> <xsl:attribute name="value"> /shop/p-<xsl:value-of select="$product/product/@id"/>-<xsl:value-of select="$product/product/@seoFriendlyUrl"/> </xsl:attribute> </input> <input type="submit" value="Add To Basket"></input> <br/> <span class="text">Quantity:</span> <input type="text" name="quantityInput" value="1"></input> </form>

    With the following code added to the Cart XSLT:

    <!-- Add product from form submitted from product page -->
    <xsl:variable name="catalogName" select="umbraco.library:RequestForm('catalog')"/>
    <xsl:variable name="postedSku" select="umbraco.library:RequestForm('sku')"/>
    <xsl:variable name="postedVariant" select="umbraco.library:RequestForm('variantSku')"/>
    <xsl:variable name="postedQuantity" select="umbraco.library:RequestForm('quantityInput')"></xsl:variable>
    
    <xsl:if test="string-length($postedSku) > 0">
        <!-- Call add to basket method -->
        <xsl:variable name="addToBasketResult" select="CommerceLibrary:AddToBasket($catalogName, $postedQuantity, $postedSku, $postedVariant)"/>
        <xsl:variable name="pipelineResult" select="CommerceLibrary:ExecuteBasketPipeline()"></xsl:variable>
    </xsl:if>
    ...
    <xsl:variable name="returnUrl" select="umbraco.library:RequestForm('returnUrl')"/>
    <a>
        <xsl:attribute name="href">
            <xsl:value-of select="$returnUrl"/>
            <xsl:if test="$returnUrl = ''">
              <xsl:value-of select="umbraco.library:NiceUrl(---)"/>
            </xsl:if>
        </xsl:attribute>
        Continue Shopping
    </a>

    I did this because I didn't want to redirect and needed a "Continue Shopping" button

Please Sign in or register to post replies

Write your reply to:

Draft