Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Minimum Product Quantity


manada

Recommended Posts

Need to make changes to the contribution 'Minimum Product Quantity with Admin' (http://www.oscommerce.com/community/contributions,2953). So far this contribution doesnt allow to customer to pick different attribute of product. When they do that thay always get new cart entry with quantity automatically set to whatever was ealier set in database. Changes I need to make are: to able customer pick differnet attributes ex. size, colors, logo location in range of minimum quantity.

 

So , let say customer would be able to buy product ex. "Elegant Man Shirt ", which minimum amount to buy is set to 12, but with attributes of: 8 pieces of XL, Red, 2 pieces XXXL, blue and 2 - whites.

 

Below is code from shopping_cart.php which i belive is essential for it.

 

//Minimum quantity code
if(MINIMUM_ORDERS == 'true'){
  $min_order_query = tep_db_query("select p.minorder as min_quant FROM " . TABLE_PRODUCTS . " p where p.products_id = '".$products[$i]['id']."'");
while ($min_order = tep_db_fetch_array($min_order_query))  {
  if ($products[$i]['quantity'] < $min_order['min_quant'] ) {
		$products[$i]['min_quant']=$min_order['min_quant'];
  }
}

 if ($products[$i]['quantity'] < $products[$i]['min_quant'] ) {
 	$products[$i]['quantity']=$products[$i]['min_quant'];
	$cart->add_cart($products[$i]['id'],$products[$i]['quantity'],$products[$i]['attributes']);
	$cart_notice = sprintf(MINIMUM_ORDER_NOTICE, $products[$i]["name"], $products[$i]["min_quant"]);
}
}
//End Minimum quantity code

 

Any help deeply appreciate

 

Adam

Link to comment
Share on other sites

Ok, I found different code from simillar contrib called Maximum Product Quantity with Admin. I grabbed this part from shopping_cart.php. Author of this code says:

That way I could run a sale on an item but still give the customer a choice about what color or size they wanted. With this contribution I can make sure they only get 1 T-shirt per order, but they can still get the size option they need.
.

 

Any idea how to turn this option to Minimum Product Quantity contrib??

 

//MAXIMUM quantity code
if(MAXIMUM_ORDERS == 'true'){
$max_order_query = tep_db_query("select p.maxorder as max_quant FROM " . TABLE_PRODUCTS . " p where p.products_id = '".$products[$i]['id']."'");
while ($max_order = tep_db_fetch_array($max_order_query))  {
	$products[$i]['max_quant']=$max_order['max_quant']; // set the cart item max var
	if (!empty($products[$i]['max_quant'])) {//add check account for if max_quant is null or '', if it is you can skip all this stuff can it's umlimited
	// okay if this product already is in basket irregardless of it's attributes selected... keep the old one
	for ($ic = 0; $ic < $i;$ic++) {
	   if (tep_get_prid($products[$i]['id']) == tep_get_prid($products[$ic]['id'])) {
	   $cart_notice .= sprintf(MAXIMUM_ORDER_DUPLICATE, $products[$i]["name"], $products[$i]["max_quant"]) . '<BR>'; // notify them they can not do that
	   $cart_skip_prod = true;
	   $cart->remove($products[$i]['id']); // remove this new item from the cart session
	   $cart_skip_prod = true; // set a flag so we can bypass output of the item that was already stuck into the products array before we removed it just now
	   }
	   else {
	   //$cart_notice .= ' - okay no match ';
	   }
	   $cart_notice .= '<BR>';
	}

	// okay now for products that have no attributes or have identical attributes
	if ($products[$i]['quantity'] > $max_order['max_quant'] ) { //add check account for if max_quant is null or '', if so let it go through.
		$products[$i]['quantity']=$products[$i]['max_quant'];
		$cart->add_cart($products[$i]['id'],$products[$i]['quantity'],$products[$i]['attributes']); // update the qty
		$cart_notice .= sprintf(MAXIMUM_ORDER_NOTICE, $products[$i]["name"], $products[$i]["max_quant"]); // notify them they can not do that
	}
	}
}
}

if ($cart_skip_prod) { // still need to skip displaying the item still stuck in $products array even though we removed it from $cart
  break;
  }
//End MAXIMUM quantity code

 

Any help deeply appreciate

 

Adam

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...