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 14 of 14

Thread: How to hide quantity field in shopping cart?

  1. #1
    sha87 is offline Member
    Join Date
    Oct 2010
    Posts
    31

    Default How to hide quantity field in shopping cart?

    I am wanting to hide the quantity field in the shopping cart and during checkout. I already found the appConfig that will hide it just for the product page.

    I've gone through the ASP Core / Control folders and looked at the Shoppingcart.cs file, but I couldn't find anything to delete the quantity field - only the header. Is there a way to do this?

    Thank you in advance!

  2. #2
    harsha.gus is offline Senior Member
    Join Date
    Mar 2009
    Posts
    301

    Exclamation I would like to do the same

    I have a Upsell product with a discount.
    it should only work like when they buy product A they get Discount on Product B.
    But later in shopping cart customer is allowed to update the quantity of the Discounted Product, this is not correct.

    So i would like to disable the update quantity for the upsell product in cart page or remove the update quantity option in the shopping cart completely.

    if any one got to implement this, please share your work here.

    thanks

    Quote Originally Posted by sha87 View Post
    I am wanting to hide the quantity field in the shopping cart and during checkout. I already found the appConfig that will hide it just for the product page.

    I've gone through the ASP Core / Control folders and looked at the Shoppingcart.cs file, but I couldn't find anything to delete the quantity field - only the header. Is there a way to do this?

    Thank you in advance!
    rbgx
    AspDotNetStorefront ML
    v8.0.1.4

  3. #3
    ChrisAtAbilityBusiness is offline Junior Member
    Join Date
    Jun 2011
    Location
    NE Ohio
    Posts
    23

    Default

    sha87,

    Is your goal to prevent this field from being edited during checkout (simpler) or to completely remove the display altogether (a little more difficult)?
    Christopher Hallam
    Business Application Development & Consulting
    Ability Business
    AspDotNetStorefront Preferred Development Partner/Reseller

  4. #4
    harsha.gus is offline Senior Member
    Join Date
    Mar 2009
    Posts
    301

    Exclamation restrict at chekout modification

    my goal is to prevent this field from being edited during checkout
    How can i achieve it.


    Quote Originally Posted by ChrisAtAbilityBusiness View Post
    sha87,

    Is your goal to prevent this field from being edited during checkout (simpler) or to completely remove the display altogether (a little more difficult)?
    rbgx
    AspDotNetStorefront ML
    v8.0.1.4

  5. #5
    ChrisAtAbilityBusiness is offline Junior Member
    Join Date
    Jun 2011
    Location
    NE Ohio
    Posts
    23

    Default

    Do you have source?
    Christopher Hallam
    Business Application Development & Consulting
    Ability Business
    AspDotNetStorefront Preferred Development Partner/Reseller

  6. #6
    harsha.gus is offline Senior Member
    Join Date
    Mar 2009
    Posts
    301

    Exclamation no I don't have the source

    no I don't have the source.

    Quote Originally Posted by ChrisAtAbilityBusiness View Post
    Do you have source?
    rbgx
    AspDotNetStorefront ML
    v8.0.1.4

  7. #7
    ChrisAtAbilityBusiness is offline Junior Member
    Join Date
    Jun 2011
    Location
    NE Ohio
    Posts
    23

    Default

    Hi,

    Sorry for the slow response.

    It will be a little more complicated without source. The steps will be:
    1. Create a class in your App_Code folder.
    2. The shoppingcart.aspx page calls a function of the ShoppingCart class called DisplayItems() that takes a few parameters.
    3. You will need to reproduce this class in some fashion, likely a function that takes the same parameters as well as the cart itself as a parameter so that you can have access to and iterate through the items in the cart.
    4. Open the shoppingcart.aspx page in a browser and View Source and locate the <table> that is generated as the display as a result of calling the cart.DisplayItems() function. This is what you will need to generate on your own through your new function and return (as a string).
    5. In your new class you will perform the necessary logic to determine whether (for each cart item) you will be displaying the quantity field as a textbox (editable) or simply a label.
    6. My recommendation is to perform the same logic in the cart update method of this shoppingcart.aspx page to make sure that these restricted item quantities do not get changed.

    If you need any further explanation on any of these steps just let me know.

    HTH
    Christopher Hallam
    Business Application Development & Consulting
    Ability Business
    AspDotNetStorefront Preferred Development Partner/Reseller

  8. #8
    harsha.gus is offline Senior Member
    Join Date
    Mar 2009
    Posts
    301

    Exclamation here is what i did.

    this is line calling Displayitems
    CartItems.Text = cart.DisplayItems(true, ThisCustomer, true);


    it is taking three parameters, Bool Quantity Read Only,Customer ViewingCustomer and bool Show item Delete Button
    I have changed Boolean parameter for Quantity Read-only as True.
    this made the quantity unmodified at shopping cart page.

    you said i can iterate through the DisplayItems() Method and disable Quantity edit only for certain products.

    Can you provide an ideal of iteration logic, what params i should take.

    thanks
    rbgx
    AspDotNetStorefront ML
    v8.0.1.4

  9. #9
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    or you could just set the restrictedquantity of the upsell item to just allow 1.


    TTFN

    BFG

  10. #10
    ChrisAtAbilityBusiness is offline Junior Member
    Join Date
    Jun 2011
    Location
    NE Ohio
    Posts
    23

    Default

    Setting the RestrictedQuantity of the Upsell Item will work if this is the only instance where you will have the item in the cart. If you wish to allow the purchase of this item separately (and in any quantity) then you will need to implement something like the following:

    This is an example pulled directly from Viewing Source of a shoppingcart.aspx page. The below snippet is the <table> that was generated from the cart.DisplayItems() function.

    HTML Code:
    <table width="100%" cellpadding="2" cellspacing="0" border="0">
    	<tr>
    		<td align="left" valign="middle"><b>Product</b></td>
    		<td align="center" valign="middle"><b>Quantity</b></td>
    		<td align="right" valign="middle"><b>Sub Total:</b></td>
    	</tr>
    	<tr>
    		<td colspan="3"><hr style="height: 1px; width:100%; color: #DDDDDD;"></td>
    	</tr>
    	<tr>
    		<td align="left" valign="top">
    			<a href="p-23-sweaters-all-styles.aspx">
    			<b>Sweaters-All styles-Cardigan-V-neck</b></a>
    			<br/>SKU: <br/>Size: Youth Lg(14-16)
    		</td>
    		<td align="center" valign="top">
    			<input type="text" name="Quantity_173" id="Quantity_173" size="4" value="1" maxlength="4" >&nbsp;
    			<input type="submit" name="bt_Delete" class="CartDeleteButton" value="Delete" onClick="document.getElementById('Quantity_173').value='0';">
    		</td>
    		<td align="right" valign="top">$27.00</td>
    	</tr>
    	<tr>
    		<td colspan="3"><hr style="height: 1px; width:100%; color: #DDDDDD;"></td>
    	</tr>
    	<tr>
    		<td align="left" valign="top">
    			<a href="p-96-pants.aspx"><b>Pants</b></a>
    			<br/>SKU: 7121<br/>Size: 7H [+$7.50]
    		</td>
    		<td align="center" valign="top">
    			<input type="text" name="Quantity_174" id="Quantity_174" size="4" value="1" maxlength="4" >&nbsp;
    			<input type="submit" name="bt_Delete" class="CartDeleteButton" value="Delete" onClick="document.getElementById('Quantity_174').value='0';">
    		</td>
    		<td align="right" valign="top">$26.00</td>
    	</tr>
    </table>
    What you will need to do is create a custom class in the App_Code folder. We will call it customlogic.cs. In that class we will create a method:
    Code:
    public static string DisplayCartItems(Customer ViewingCustomer, bool ShowItemDeleteButton, ShoppingCart cart){...}
    Notice that we have removed the first parameter. As we are making this determination ourselves on a per item basis we do not need a parameter to make the determination for all items. Also notice we have added a ShoppingCart class parameter.

    Replace the line of code:
    Code:
    CartItems.Text = cart.DisplayItems(true, ThisCustomer, true);
    with:
    Code:
    CartItems.Text = customlogic.DisplayCartItems(ThisCustomer, true, cart);
    This will call our new custom function instead of the built-in cart method.

    For our custom function we will want to do something like this (keep in mind our goal is to generate the exact same <table> as the original function with the exception of the quantity field):

    Code:
    public static string DisplayCartItems(Customer ViewingCustomer, bool ShowItemDeleteButton, ShoppingCart cart)
    {
      StringBuilder sb = new StringBuilder();
    
      sb.Append("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">");
    
      sb.Append("<tr>");
      sb.Append("<td align=\"left\" valign=\"middle\"><b>Product</b></td>");
      sb.Append("<td align=\"left\" valign=\"middle\"><b>Quantity</b></td>");
      sb.Append("<td align=\"left\" valign=\"middle\"><b>Sub Total:</b></td>");
      sb.Append("</tr>");
    
      foreach (CartItem ci in cart.CartItems)
      {
        sb.Append("<tr>");
        sb.Append("<td colspan=\"3\"><hr style=\"height: 1px; width: 100%; color: #DDDDDD;\"></td>");
        sb.Append("</tr>");
    
        sb.Append("<tr>");
    
        sb.Append("<td align=\"left\" valign=\"top\">");
        // INSERT LOGIC HERE TO GENERATE IMAGE (IF DESIRED) AND PRODUCT NAME/LINK
        sb.Append("</td>");
    
        sb.Append("<td align=\"left\" valign=\"top\">");
        // INSERT LOGIC HERE TO DETERMINE IF THIS ITEM WILL DISPLAY AN EDITABLE TEXTBOX FOR QUANTITY AND A DELETE BUTTON OR ELSE SIMPLY A LABEL
        sb.Append("</td>");
    
        sb.Append("<td align=\"left\" valign=\"top\">");
        // INSERT LOGIC HERE TO GENERATE PRODUCT PRICE
        sb.Append("</td>");
    
        sb.Append("</tr>");
      }
    
      sb.Append("</table>");
    
      return sb.ToString();
    
    }
    HTH


    Edited to: Insert missing sb.Append("<tr>"); line in code.
    Last edited by ChrisAtAbilityBusiness; 07-08-2011 at 09:33 AM.
    Christopher Hallam
    Business Application Development & Consulting
    Ability Business
    AspDotNetStorefront Preferred Development Partner/Reseller

  11. #11
    harsha.gus is offline Senior Member
    Join Date
    Mar 2009
    Posts
    301

    Exclamation

    Hi chris,
    I really appreciate your help.
    I just have one last question, where can i find any exiting code for retrieving the product details for
    // INSERT LOGIC HERE TO GENERATE IMAGE (IF DESIRED) AND PRODUCT NAME/LINK
    // INSERT LOGIC HERE TO DETERMINE IF THIS ITEM WILL DISPLAY AN EDITABLE TEXTBOX FOR QUANTITY AND A DELETE BUTTON OR ELSE SIMPLY A LABEL
    // INSERT LOGIC HERE TO GENERATE PRODUCT PRICE

    i see that the product information is generated from the XML.Config files with Xpath,

    how can i call the product details in to the new customlogic class.

    thanks
    rbgx
    AspDotNetStorefront ML
    v8.0.1.4

  12. #12
    ChrisAtAbilityBusiness is offline Junior Member
    Join Date
    Jun 2011
    Location
    NE Ohio
    Posts
    23

    Default

    This is going to be fairly complex and lengthy. Do you have a copy of the storefront around with full source that you can reference?

    As far as displaying these items there are SO many config settings that can affect this.

    For example the product link; whether or not the cart should display pictures, whether those pictures should be watermarked.

    For example the quantity: you will need to perform your own custom logic to determine whether the given product is one of the upsell items that needs to have an un-editable qty or else to allow for a textbox that can be edited. whether to allow for the delete button or not.

    For example the subtotal: customer level discounts, VAT, quantity discounts, etc will all play a role in calculating the displayed subtotal.

    If you do not have source we can walk through it but it is going to be lengthy.

    Thanks,
    Christopher Hallam
    Business Application Development & Consulting
    Ability Business
    AspDotNetStorefront Preferred Development Partner/Reseller

  13. #13
    new2011 is offline Junior Member
    Join Date
    May 2011
    Posts
    7

    Default I would like to hide price

    Hi Chris,

    I saw your post. I use 9.0. Do you have any suggestions for 9.0? Thanks in advance!!

  14. #14
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    The 'easy' way to do this would be to create a duplicate of the product you are discounting & set the restricted quantity to 1.

    Then people can buy the regular product at full price in whatever quantity they like & they are limited to only one of the discounted product.


    No source code, no modifications, can set it up in less than a minute.


    TTFN

    BFG