Jump to content

Maximum Quantity Per Item


glynwilliams
 Share

Recommended Posts

Hi there, 

Being as I'm new to Cubecart I apologise if the questions I'm asking are very basic.

I was wondering if there is the facility to restrict the maximum quantity of a single item within an order ?

Is it possible to not accept an order for an item based on the delivery address ? eg only available within the UK ?

Is it possible to print off a number of delivery labels for different orders ?

Thanks in advance for any help.

Kind Regards

Glyn.

Link to comment
Share on other sites

Welcome glynwilliams! Glad to see you made it to the forums.

When adding or editing a product, the Pricing tab has a setting to force the customer to purchase a minimum number of this item. We can easily customize the code to set a maximum as well.

Almost every payment module (called 'gateways') has a tab on the settings page to allow specific countries. If United Kingdom is added to this list, then this method of payment will only be available to addresses in this country.

In admin, Orders, each order in the list of orders has a leading checkbox. This checkbox will then select this order to be handled according to the selectors at the bottom of the list. One option is to print an invoice. The "Invoice" document includes an area that can be cut off to use as a shipping label. (Otherwise, CubeCart does not currently have the ability to print addresses on a sheet of peel-n-stick shipping labels.)

 

Link to comment
Share on other sites

  • 2 weeks later...

These edits will add the capability to restrict a customer to being able to purchase a maximum quantity of a product.

If assistance is required, please let us know.

Add the new column to the CubeCart_inventory table:

ALTER TABLE `CubeCart_inventory`
	ADD COLUMN `maximum_quantity` INT(10) NULL DEFAULT NULL AFTER `minimum_quantity`;



Add the following to /language/definitions.xml:
In the group 'catalogue':
<string name="error_maximum_quantity"><![CDATA[Maximum quantity allowed for this item is %s!]]></string>
<string name="max_purchase_quantity"><![CDATA[Maximum purchase quantity is %s.]]></string>
<string name="maximum_quantity"><![CDATA[Maximum Quantity Purchase]]></string>



In the skin template element.product.call_to_action.php, find:
<input type="number" name="quantity" value="{$PRODUCT.minimum_quantity}" min="{$PRODUCT.minimum_quantity}" maxlength="3" class="quantity required text-center">

Change to:
<input type="number" name="quantity" value="{$PRODUCT.minimum_quantity}" min="{$PRODUCT.minimum_quantity}"{if $PRODUCT.maximum_quantity gte $PRODUCT.minimum_quantity}max="{$PRODUCT.maximum_quantity}"{/if} maxlength="3" class="quantity required text-center">

Find:
   {if $PRODUCT.minimum_quantity>1}
   <small>{$LANG.catalogue.min_purchase_quantity|replace:'%s':$PRODUCT.minimum_quantity}</small>
   {/if}

Change to:
   {if $PRODUCT.minimum_quantity>1}
  <div class="small-12 columns" style="line-height:0.75;">
   <span style="font-size:x-small;">{$LANG.catalogue.min_purchase_quantity|replace:'%s':$PRODUCT.minimum_quantity}</span>
  </div>
   {/if}
   {if $PRODUCT.maximum_quantity gte $PRODUCT.minimum_quantity}
  <div class="small-12 columns" style="line-height:0.75;">
    <span style="font-size:x-small;">{$LANG.catalogue.max_purchase_quantity|replace:'%s':$PRODUCT.maximum_quantity}</span>
  </div>
   {/if}



In the file /classes/cart.class.php, near line 456, find:
public function checkMinimumProductQuantity($productID, $quantity, $redirect=true)

A few lines later, find:
$min_q = (int)$data['minimum_quantity'];

On a new blank line after that, add:
$max_q = (int)$data['maximum_quantity'];

A few lines later, find:
return false;

Above that, add:
if ($max_q && $max_q < $quantity) {
    $GLOBALS['gui']->setError(sprintf($GLOBALS['language']->catalogue['error_maximum_quantity'], $max_q));

    if ($redirect) {
        $this->redirectToProductPage($productID);
    }
}



In the admin skin template products.index.php, near line 271, find:
<div><label for="minimum_quantity">{$LANG.catalogue.minimum_quantity}</label><span><input name="minimum_quantity" id="minimum_quantity" class="textbox number-right" type="text" value="{$PRODUCT.minimum_quantity}"></span></div>

On a new blank line after that, add:
<div><label for="maximum_quantity">{$LANG.catalogue.maximum_quantity}</label><span><input name="maximum_quantity" id="maximum_quantity" class="textbox number-right" type="text" value="{$PRODUCT.maximum_quantity}">&nbsp;{$LANG.common.blank_to_disable}</span></div>

 

Link to comment
Share on other sites

Hi there

Thanks for this, it looks like good news.

I guess that after the code has been implemented, we can optionally set a max quantity for certain items but we don't have to it for all.

On that basis can you go ahead and implement the code change into our environment.

Thanks in advance.

Glyn.

 

Link to comment
Share on other sites

  • 10 months later...

hi all!

I' m using cubecart v6.4.4

One of my products is showing a 'maximum purchase quantity'.  Problem is , I cannot change this and it is on '0'.
can anymone help me to find out where I can modify this?  
I found the "minium" to modify but not this new feature of the maximum ?

thank you very much

stef

Link to comment
Share on other sites

Is this setting not being shown: admin, Edit a Product, Pricing tab, "Maximum Quantity Purchase"?

If the setting is showing, please read:

https://forums.cubecart.com/topic/57097-disable-maximum-purchase-amount/
https://github.com/cubecart/v6/issues/2903

 

Edited by bsmither
Link to comment
Share on other sites

hello,

thank you very much !

in fact : no!

on the admin, Edit a Product, Pricing tab.  I only see:

  • retail price
  • sale price
  • cost price
  • tax class
  • tax included
  • minimum quantity purchase

! no "maximum"

But I've just noticed that if I change the minimum from '0' to '1', that the little phrase 'maximum purchase quantity:0' has dissapeared.

all OK then !

thank you for helping me out !!!

stef

Link to comment
Share on other sites

Something didn't get upgraded properly.

Or, it could be that the upgrade process left the following situation:

In the main directory where CubeCart is installed, there may be more than one folder that begins with 'admin', such as /admin/, and also /admin_rAnDoM/.

One will be the version you upgraded from and the other will be the version you upgraded to. The date of the folder will indicate which is the latest version.

In the file /includes/global.inc.php, there will be a reference to the administration file and folder that may indicate the older version. They need to indicate the newer version. (The administration PHP script file did not change, but did take on a new filename.)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...