Jump to content

Maximum Quantity Per Item


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

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...