If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / How can I stop people from adding more to cart than what's in stock?

How can I stop people from adding more to cart than what's in stock?

Locked

Started by chandy on 5 Dec 2009, 9:41 PM · Views: 876

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
5 Dec 2009, 9:41 PM
#1
chandy avatar

chandy

New Zenner

Join Date:
Feb 2007
Posts:
25
Plugin Contributions:
0

How can I stop people from adding more to cart than what's in stock?

Hi,

Is there an addon or code available that will link the maximum number of items for a line to the stock available? Or can I customise the basket and/or product screen to show the actual stock left intead of *** if they add too much?

Thanks.

5 Dec 2009, 10:26 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I stop people from adding more to cart than what's in stock?

You could customize the shopping cart to display the quantity available with the function:

/**
 * Return a product's stock count.
 *
 * @param int The product id of the product who's stock we want
*/
  function zen_get_products_stock($products_id) {

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Dec 2009, 11:17 AM
#3
chandy avatar

chandy

New Zenner

Join Date:
Feb 2007
Posts:
25
Plugin Contributions:
0

Re: How can I stop people from adding more to cart than what's in stock?

Can I add this to the product page too?

Is this not a common customisation? I'm surprised it's not built-in tbh.

6 Dec 2009, 11:53 AM
#4
chandy avatar

chandy

New Zenner

Join Date:
Feb 2007
Posts:
25
Plugin Contributions:
0

Re: How can I stop people from adding more to cart than what's in stock?

Can someone tell me which file contains the code where the product details are shown so I can make this change?

I am not familiar with the guts of the codebase so some guidance as to what to change would be good too :)

6 Dec 2009, 2:07 PM
#5
chandy avatar

chandy

New Zenner

Join Date:
Feb 2007
Posts:
25
Plugin Contributions:
0

Re: How can I stop people from adding more to cart than what's in stock?

Ok, the Max:Qty from the product page seems to be wrapped up in zen_get_products_quantity_min_units_display

Where can I find this defined and should I really be changing it?

I have decided the best approach is to tie the max to the stock directly in the products page first of all.

Thanks.

6 Dec 2009, 4:00 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I stop people from adding more to cart than what's in stock?

By default, the Maximum Value is not designed to work with the stock as a stop on the quantity being ordered ...

You could, however, customize it so that the Maximum changes with the stock quantity ...

This could either be done in the order class where the stock quantity is updated or elsewhere in the program such as the function where the button is made or the price is made ...

The button for the Add to Cart and Buy Now is built in the function_general ...

////
// Switch buy now button based on call for price sold out etc.
  function zen_get_buy_now_button($product_id, $link, $additional_link = false) {
    global $db;

You could add something to update the maximum there ... but you need to test if this is sufficient for listings as well as product _info and the shopping cart ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!