#1289 ✓resolved
BJ Kline

Feature request: purchase product in required multiple quantities

Reported by BJ Kline | April 24th, 2015 @ 07:19 PM

I have a product I will be selling that only comes in multiples of 5. The customer should not be allowed to order say 8 of this item. If they try to order 8 then the system needs to automatically adjust to 10. I have set the Minimum order quantity to 5, but I didn't see a way to handle more than 5. Is there a way to make this happen in Exponent?

Comments and changes to this ticket

  • dleffler

    dleffler April 25th, 2015 @ 03:10 PM

    • Tag set to ecommerce
    • Assigned user changed from “expNinja” to “dleffler”

    Not at present...what would be an acceptable solution?

    • Quantity auto-adjusted up, or down to nearest multiple?
      • the cart addition takes place, but is fixed
      • e.g., if they order 8, they get 10 in the cart
    • Notice message given that the quantity is unacceptable?
      • the cart addition is not allowed to take place
      • e.g., nothing else done until they correct the issue/quantity
  • BJ Kline

    BJ Kline April 25th, 2015 @ 08:14 PM

    An acceptable solution is to have the Quantity auto-adjusted up or down to nearest multiple.

  • BJ Kline

    BJ Kline April 28th, 2015 @ 02:00 PM

    So I've been looking around to see if I can come up with a solution. I found a formula that will do the adjusting.

    if (pkg_qty % o_pkg_qty != 0) {
                        pkg_qty = (Math.floor(pkg_qty / o_pkg_qty) + 1) * o_pkg_qty;
    jQuery('#desc' + trid_num).append('<br/><div class="blueBox">Package qty is ' + o_pkg_qty + ', qty updated to ' + pkg_qty + '</span>');
    jQuery('#qty' + trid_num).val(pkg_qty);

    I think you'd set o_pkg_qty = to the number you want to order, then pkg_qty = to the minimum order quantity. What I haven't been able to work out is how to implement this in Exponent.

  • dleffler

    dleffler April 28th, 2015 @ 05:07 PM

    Probably a bit more complicated based on my initial work (which is somewhat based on how we handle minimum quantities)

    • add a 'quantity_multiple field to the product definition
    • add a control in all the product 'edit' views to allow the entry of this value
    • add a 'note' in each of the show views regarding the multiple quantities required (like we do for minimum quantity)
      • I wasn't planning to worry about adjusting the entered quantity value on the view like your have above)
    • update the cartController->addItem() AND cartController->updateQuantity() code to adjust the quantity up if needed...and if so spit out a queue message saying we've done so
    • may also have to add code to the product->addToCart() and product->createOrderItem() to create a complete solution
  • BJ Kline

    BJ Kline April 28th, 2015 @ 06:24 PM

    In my case this only needs to happen on products that have a minimum quantity value set. These products are only available as multiples of 5.

    Could something like this work?

    {$pkg_qty = $product->minimum_order_quantity}
    {$o_pkg_qty = $orderItem->quantity}

    {if $orderItem->quantity >= 5 && $product->minimum_order_quantity == 5} //I'm not sure what Exponent uses to store the quantity {if pkg_qty % o_pkg_qty != 0 } ceil(pkg_qty / o_pkg_qty) + 1) * o_pkg_qty {/if} {/if}
  • dleffler

    dleffler April 28th, 2015 @ 06:46 PM

    What you had just written would only work as the page is built and we already set the 'quantity' input to the minimum quantity. And your jquery code would generally work if you attach it to an event such as form submit or input blur.

    If you're willing to make the assumption the minimum quantity is the multiple quantity (which should work in your case), you can do something like we do with YUI3 in the ecommerce/views/store/showGiftCards.tpl file (plus some others), where we simply wait on the 'blur' event for the 'quantity field, then adjust it programmatically in the appropriate store/show.tpl view something like (HOWEVER there is a caveat)

    {if $product->minimum_order_quantity > 1}
    {script unique="prod_mult" yui3mods="node"}
        YUI(EXPONENT.YUI3_CONFIG).use('*', function(Y) {
            var bp = {/literal}{$product->minimum_order_quantity}{literal};
            var da = Y.one('#quantity');
            da.on('blur', function(e,o){
                var newint = parseInt(e.target.get('value');

    While in theory this could work, a customer can purchase the product in quantity on many different views...my approach (in the next release code) will be to make it a more site-wide universal approach in the backend processing.

  • BJ Kline

    BJ Kline April 28th, 2015 @ 07:47 PM

    How long until the new release? Is your approach currently in the development branch? I've got a bunch more products to include in the catalog yet, so the site's not ready to go live yet. However if there isn't a timeframe to implement this, I will have to switch to a different platform.

  • dleffler

    dleffler April 29th, 2015 @ 02:03 AM

    No specific timeframe for next release, but may try for next week (it will likely be v3.3.4 since a v233patch2 would be over 5 megabytes at this point). I haven't pushed up my partial work on quantity multiple to the develop branch yet since it's unfinished, but hope to have it up on 'develop' before the end of the week.

  • dleffler

    dleffler April 29th, 2015 @ 10:55 AM

    FWIW, I've not seen this feature on other ecommerce software packages...some don't even offer the minimum quantity option.

  • dleffler

    dleffler April 29th, 2015 @ 01:54 PM

    • Title changed from “E-Commerce: Order in multiple quantities” to “Feature request: purchase product in required multiple quantities”

    This is for a 'parent' product and NOT child products, correct? Currently we only process minimum quantity for the parent products and don't check it with child products.

  • BJ Kline

    BJ Kline April 29th, 2015 @ 02:25 PM

    Yes these are 'parent' products.

  • expNinja

    expNinja April 30th, 2015 @ 12:38 PM

    • State changed from “new” to “resolved”
  • dleffler

    dleffler April 30th, 2015 @ 12:40 PM

    Must perform a update database tables to add new field. Performs identical to 'minimum quantity' in regards to operation and user feedback

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Bug Tracker for Exponent CMS

Shared Ticket Bins

People watching this ticket