Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to force a total product quantity to 1 in cart


concorde44

Recommended Posts

Posted

Hi,

I was looking on the forums for this answer, without finding it.
I created a product as a gift, with a value of 0 and quantity of 1000pcs in stock.
So I was looking for a solution to only give one gift even if the customer tries to change it qty to 2 or more.

So I dig it and here is the answer

Includes\classes\shopping_cart.php

find function update_quantity

Find : $this->contents[$products_id_string] = array('qty' => $quantity);

replace with

$gift=array('1045','14'}; // modify with the id's of products you want only 1 in hte cart
if (in_array($products_id, $gift)) { 
		$this->contents[$products_id_string] = array('qty' => '1'); // Force total qty to only 1
	} else {
		$this->contents[$products_id_string] = array('qty' => $quantity);
	}

 

Hope this helps

Seb

Osc 2.2 MS2

Archived

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

×
×
  • Create New...