Quantity Field, fixed amounts instead of open text field

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
jdarby
Commander (CMDR)
Commander (CMDR)
Posts: 151
Joined: Thu Sep 25, 2008 2:21 pm

Quantity Field, fixed amounts instead of open text field

Post by jdarby » Fri Apr 13, 2012 10:51 am

I have a product that will need to be sold only in multiples of 6 (6, 12, 18, 24, etc.)

Currently, the Quantity field on the product page is an open text field that will allow the user to enter any number in and purchase however many of the product they would like. Is there an option that allows me to change the Quantity box to a dropdown and only allow the product to be purchased in certain quantities? Or is my only option to call the product something like "Glass (6-Pack)" and leave it with an open text Quantity field and manage it that way?

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Quantity Field, fixed amounts instead of open text field

Post by david-ebt » Fri Apr 13, 2012 12:43 pm

There isn't a built-in option for this.

To do this you would have to modify the ConLib\BuyProductDialog control. And unless all of your products have these quantity 6-pack constraints, you would need two versions of the product page and a way to switch between them. One version for standard products and another for the 6-pack products. If you have more packaging options then the variables multiply. And, if your search results or category pages let users select a quantity before adding to their cart, you would also need to update those controls for both product types.

The simplest approach is your "Glass (6-pack)" idea. I see a lot of sites that take that approach so I don't think it would confuse your customers.
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

mouse_8b
Commander (CMDR)
Commander (CMDR)
Posts: 115
Joined: Mon Oct 11, 2010 1:21 pm
Location: Austin, TX
Contact:

Re: Quantity Field, fixed amounts instead of open text field

Post by mouse_8b » Fri Apr 13, 2012 3:58 pm

We did this for pet food sold in cases of 12. Our inventory is recorded in number of cans, but for our online orders, we only sell it by the case. I made a custom BuyProductDialog.ascx.cs where I just divided the available quantity by 12 and added the word " Cases" to the in stock message. Dividing the inv.InStock by 12 prevents customers from ordering more than we have and rounds down in the instance of a partial case being in stock. The only down side to this is that they can still raise the quantity on the basket page, since that quantity check won't do the division.

Here's the only code that I changed in BuyProductDialog.ascx.cs:

Code: Select all

if ((inv.InventoryMode == InventoryMode.None) || (inv.AllowBackorder)) return;
//Added
//Divide stock by 12 to get number of cases.
inv.InStock /= 12;
if (inv.InStock > 0)
{
   string inStockformat = Token.Instance.Store.Settings.InventoryInStockMessage;
   string inStockMessage = string.Format(inStockformat, inv.InStock + " Cases");  //added " Cases"
   InventoryDetailsPanel.Controls.Clear();
I did have to make new, renamed copies of Product.aspx, the Show Product content scriptlet, and the ConLib control BuyProductDialog.ascx. The .aspx page is identical to Product.aspx, the content scriptlet has "Case of 12" after the product name, and in the new BuyProductDialog.ascx, the CodeFile value points to the new BuyProductDialog.ascx.cs. With this setup I just have to change the product's display page for products that come in cases.

Here is an example of this in action: http://www.barknpurr.com/Instinct-Chick ... 7C366.aspx. I also added "Case of 12" to the product summary so that information is available on the category page.

Post Reply