Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 13 of 13

Thread: Total Amount in Cart

  1. #1
    tmoney101 is offline Senior Member
    Join Date
    Oct 2007
    Posts
    152

    Default Total Amount in Cart

    I want to display in my skin, the amount of items in the shopping cart plus the total amount in the cart.

    I know I can display the amount of items using the skin token (!NUM_CART_ITEMS!) however how do I display the total amount in the cart? Like the amount of cash that the cart items have added up to?

    I have looked but there doesnt seem to be a token for it?

  2. #2
    ASPDNSF Staff – Eirol is offline Senior Member
    Join Date
    May 2008
    Posts
    182

    Default

    Have you tried the (!MINICART!) token? It display on whats in your shopping cart.

  3. #3
    tmoney101 is offline Senior Member
    Join Date
    Oct 2007
    Posts
    152

    Default

    I do know about that, however I believe the mini cart displays all the products in your cart? This isnt what we want. We simply want the total number of items in the cart and the total amount. Eg:

    Items: 3
    Price: $345

    Any ideas?

  4. #4
    jgrimm is offline Junior Member
    Join Date
    Dec 2006
    Location
    Washington
    Posts
    2

    Default

    Yep, I wanted the same thing on our upholstery site and found the same problem, no existing token for it. So i modified the source to add one in ;-)

    If you have the source you can add one too. The modification is done in ASPDNSFCommon\parser.cs (the lines without the plus in front are existing lines you should be able to find in the file, the lines with pluses you will need to add, without the pluses of course)


    Code:
                    tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.ShoppingCart).ToString();
                    m_DynamicTokens.Add("(!NUM_CART_ITEMS!)", tmpS);
    +
    +                //USERMOD - add cart subtotal 
    +                ShoppingCart cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
    +                tmpS = ThisCustomer.CurrencyString(cart.SubTotal(true, false, true, true));
    +                m_DynamicTokens.Add("(!CART_SUBTOTAL!)",  tmpS);
    +
                    tmpS = AppLogic.GetString("AppConfig.CartPrompt", SkinID, ThisCustomer.LocaleSetting);
                    m_DynamicTokens.Add("(!CARTPROMPT!)", tmpS);
    after recompiling the Common DLL you should have a new token available to you called !CART_SUBTOTAL!

    Hope that helps!

  5. #5
    Jesse is offline Banned
    Join Date
    May 2008
    Posts
    1,329

    Default

    That's actually an excellent modification. I'll forward this to the dev team for consideration of inclusion into a future revision of ML.

  6. #6
    jazzylily is offline Member
    Join Date
    Nov 2007
    Posts
    36

    Default Total amount of items in cart

    has this been included? I would like to show the amout of items in the cart too. How can i do this without changing the source?

  7. #7
    George the Great is offline Senior Member
    Join Date
    Nov 2006
    Location
    Cleveland, OH
    Posts
    1,792

    Default

    It's not included, but simple enough to do without the source code. Open the App_Code/SkinBase.cs file, and find the ReplaceTokens method. In it, you can add two lines
    Code:
    ShoppingCart cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
    
    s = s.Replace("(!CARTTOTAL!)", Localization.CurrencyStringForDisplayWithoutExchangeRate(cart.SubTotal(true, false, true, true, true), ThisCustomer.CurrencySetting));
    and then you can use the token you've created (in this case I called it (!CARTTOTAL!), but you can use whatever you want as long as it doesn't conflict with an existing token name) in your skin to display the total amount in the shopping cart.
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>

  8. #8
    jazzylily is offline Member
    Join Date
    Nov 2007
    Posts
    36

    Default

    Anyway i can do this in the DNN Version? Do I have to put it in an XML package? How would I do this? Thanks

  9. #9
    jazzylily is offline Member
    Join Date
    Nov 2007
    Posts
    36

    Default

    figured it out.
    <xsl:value-of select="count(/root/ShoppingCart)" />

  10. #10
    isaleproducts is offline Junior Member
    Join Date
    Mar 2009
    Posts
    2

    Default Which method is faster?

    Could you let me know which method is faster? I have full source code so I can use any of them but would like to know which one is faster to use.

  11. #11
    MelanieA is offline Junior Member
    Join Date
    Sep 2008
    Posts
    313

    Default

    It is much safer to use George's suggestion since this no need to recompile your solution and will replace another assembly file.

    "It's not included, but simple enough to do without the source code. Open the App_Code/SkinBase.cs file, and find the ReplaceTokens method. In it, you can add two lines

    Code:
    ShoppingCart cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
    
    s = s.Replace("(!CARTTOTAL!)", Localization.CurrencyStringForDisplayWithoutExchangeRate(cart.SubTotal(true, false, true, true, true), ThisCustomer.CurrencySetting));
    and then you can use the token you've created (in this case I called it (!CARTTOTAL!), but you can use whatever you want as long as it doesn't conflict with an existing token name) in your skin to display the total amount in the shopping cart."

  12. #12
    isaleproducts is offline Junior Member
    Join Date
    Mar 2009
    Posts
    2

    Default Thanks

    I have followed the suggestion and it's currently working great. You can view the results here at: http://www.isaleproducts.com

    Thanks so much for the reply. I just love aspdotnetstorefront.

  13. #13
    ecitrevor is offline Junior Member
    Join Date
    Sep 2009
    Posts
    1

    Default

    I'm trying to do this same thing in version 9 of the storefront, and I am having some trouble implementing it.

    I've gone into SkinBase.cs and found the ReplaceTokens section around line 915, but I'm unsure if I'm putting the two lines of code in the right place. Also, when calling the token in the template.master file, should the code look like this?

    Code:
    <asp:Literal runat="server" Text='<%$ Tokens:CARTTOTAL %>' />
    Anyways, it isn't working the way I have it set up right now. I'm still adjusting to the changes made to the most recent version. Any help is much appreciated!