Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Setting Shopping Cart Limits


thomaselaursen

Recommended Posts

Posted

I'm developing a new store and have a theory I need to implement before launch. The store sells 240 individual products each set to "1" quantity.

 

As items are sold they are then "unavailable", ok no problem so far.

 

I set up a limit of one "quantity per product" so the customer can only order one of any product. If they try to order "2" it resets the cart to "1". That's also great so far.

 

if ($products[$i]['quantity'] > 1 ) {

	 $products[$i]['quantity']=1;

	 echo '<script language="javascript">alert ("Maximum order quantity is 1 Booth.\nYour cart has been updated to reflect this.");</script>';
  }

 

The problem is I want a customer to be only able to have one product with one quantity for checkout.

 

Then they can't order again if there is a order in their history. I'd have to delete the order before they could order again.

 

So.... here's my concept formula:

 

if cart = >1 product && >1 quantity {
 alert "Nice try you can only order one";
    else
      if cart == 1 product  &&  1 quantity {
      true;
      }
}

 

Yes that's "Thomas" scripting right there, it's only compatible in MSIE 2.0, seriously if anyone can offer some PHP advice on that I'd so appreciate it.

 

Thomas

  • 3 weeks later...
Posted

try this look for \includes\classes\shopping_cart.php

 

    function calculate() {
     $this->total = 0;
     $this->weight = 0;
     if (!is_array($this->contents)) return 0;

     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
       $qty = $this->contents[$products_id]['qty']=1;

// products price

 

notice that there is a =1 on the end of this code

original is

 

$qty = $this->contents[$products_id]['qty'];

 

modified

 

$qty = $this->contents[$products_id]['qty']=1;

 

 

then you can use this code together

 

if ($products[$i]['quantity'] > 1 ) {

 $products[$i]['quantity']=1;

 echo '<script language="javascript">alert ("Maximum order quantity is 1 Booth.\nYour cart has been updated to reflect this.");</script>';
 }

 

hope it works for you

  • 2 months later...
Posted

Could I use this code to limit the quantity available to order at any one time to 10 for a single product?

 

If so, how could I acheive this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...