Forcing item to be sold in multiples

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Forcing item to be sold in multiples

Post by Brewhaus » Mon Aug 25, 2014 1:14 pm

We have a group of products that we only sell in multiples of 12 due to customization. I cannot find in AC Gold R6 that this is possible, and on the forum I only found a method for AC7 (via manipulating files and scriptlets, which AC Gold does not appear to use). Has anyone managed this with Gold R6, or can offer insight on how to go about this?
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Forcing item to be sold in multiples

Post by mazhar » Thu Aug 28, 2014 8:05 am

You can try two things here. First from admin edit product page set the minimum purchase quantity for product to 12. This will make sure when some one will add product from category listings it will have a quantity of 12. Secondly on product details page where you can change product quantity it will be initialized with value 12 and won't let you put any thing less then it. In order to make sure value is always multiple of 12 you can use ASP.NET custom validator with some javascript to make the happen.

Edit Website/ConLib/BuyProductDialog.ascx file and locate following location

Code: Select all

<asp:PlaceHolder ID="QuantityLimitsPanel" runat="server" EnableViewState="false"></asp:PlaceHolder>
and then update it like

Code: Select all

<script type="text/javascript">
                            function validateMultiples(source, arguments) {
                                if (arguments.Value % 12 == 0) {
                                    arguments.IsValid = true;
                                } else {
                                    arguments.IsValid = false;
                                }
                            }
                        </script>
                        <asp:CustomValidator ID="MultipleQuantityValid" runat="server" ControlToValidate="Quantity" ClientValidationFunction="validateMultiples" ValidationGroup="AddToBasket" Text="*" ErrorMessage="Quantity must be multiple of 12."></asp:CustomValidator>
                        <asp:PlaceHolder ID="QuantityLimitsPanel" runat="server" EnableViewState="false"></asp:PlaceHolder>
Hopefully that will help.

ChipWV
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 88
Joined: Tue Feb 03, 2009 12:51 pm

Re: Forcing item to be sold in multiples

Post by ChipWV » Thu Aug 28, 2014 8:13 am

How about creating a kit of 12? Customer orders 2 kits they get 24, ect.

Hope this helps.

Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Re: Forcing item to be sold in multiples

Post by Brewhaus » Thu Aug 28, 2014 8:14 am

Thank you, Mazhar. Will we need to create a new Product.ascx and .cs page, and a new BuyProductDialog.ascx and .cs file so that only certain products are forced to purchase in multiples of 12?
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot

Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Re: Forcing item to be sold in multiples

Post by Brewhaus » Thu Aug 28, 2014 8:18 am

That is a good idea, Chip. I will look at both options and decide.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Forcing item to be sold in multiples

Post by mazhar » Thu Aug 28, 2014 8:24 am

Brewhaus wrote:Thank you, Mazhar. Will we need to create a new Product.ascx and .cs page, and a new BuyProductDialog.ascx and .cs file so that only certain products are forced to purchase in multiples of 12?
Actually you can make one more small code update to make this happen. Edit Website/ConLib/BuyProductDialog.ascx.cs file and locate following code

Code: Select all

if (Quantity.MinValue > 0) Quantity.Text = Quantity.MinValue.ToString();
and update it like

Code: Select all

if (Quantity.MinValue > 0) Quantity.Text = Quantity.MinValue.ToString();
MultipleQuantityValid.Visible = _Product.MinQuantity > 0 && _Product.MinQuantity == 12;
This will make this custom validator only work when a product has minimum quantity set to 12.

Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Re: Forcing item to be sold in multiples

Post by Brewhaus » Thu Aug 28, 2014 8:41 am

Thank you, Mazhar. I will test this out later today when I get the time. :-)
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot

Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Re: Forcing item to be sold in multiples

Post by Brewhaus » Thu Aug 28, 2014 10:58 am

Your solution worked perfectly, Mazhar. Thank you again!
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot

Post Reply