Post by groundcreative » Mon Oct 27, 2014 3:07 pm

I'm looking for a module that allows you to set quantity multiples required in the cart before proceeding to checkout, ie 6, 12, 18 etc. I've found plenty that allow you to set minimum and maximum quantities but nothing for multiples of quantities. Does anyone know if this is possible or could point me in the right direction?

thanks!


Posts

Joined
Mon Oct 27, 2014 3:00 pm

Post by groundcreative » Thu Oct 30, 2014 9:22 am

anybody???
This is beyond my skill level but would reeeaaaly appreciate some help! I basically just need a message that displays if someones cart total is outside the required multiples. ie "Orders must be in multiples of 6 to proceed to checkout"

Thanks!


Posts

Joined
Mon Oct 27, 2014 3:00 pm

Post by uksitebuilder » Thu Oct 30, 2014 4:10 pm

You should sell the product as a pack of 6 in that case

So customers won't get confused, by having to input 6,12, 18 for the quantity, they can simply choose 1,2,3,4 packs of 6

ImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by groundcreative » Thu Oct 30, 2014 4:54 pm

issue is though we want the customers to be able to choose multiple products to make up the six pack.
ie they could buy 2 of product A, 3 of product B & 1 of product C.


Posts

Joined
Mon Oct 27, 2014 3:00 pm

Post by uksitebuilder » Thu Oct 30, 2014 6:00 pm

Oh right, I see now.

So you need a control on the checkout that redirects them back to cart with a message, if the total of all quantities is not divisable by 6

Or will there be other products that do not come in to the equasion ?

ImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by groundcreative » Thu Oct 30, 2014 7:16 pm

Yes that's right.
No doesn't matter what's actually in the cart as long as the total is in multiples of six


Posts

Joined
Mon Oct 27, 2014 3:00 pm

Post by groundcreative » Mon Nov 03, 2014 7:58 am

Sorry just to elaborate, reason cart must equal six is for packaging/shipping reasons. The products are all wine so we need them to make up a 6 (or 12 or 18 etc) pack so that packaging and delivery is much easier.
Any suggestions???

Thanks!


Posts

Joined
Mon Oct 27, 2014 3:00 pm

Post by Qphoria » Mon Nov 03, 2014 10:52 pm

I believe this is what you are looking for:
http://forum.opencart.com/viewtopic.php ... 3&p=375586

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by groundcreative » Tue Nov 04, 2014 8:21 am

Thanks Qphoria but unfortunately that's not what I was after.
I'm not looking to force stepping on products, I want the customer to choose what ever quantities of any product they like, but then when in the cart if they try to proceed to checkout and the total isn't in a multiple of six then they get a little message saying something like "orders must be placed in multiples of 6 bottles".
Ideally I'd like something that behaves like the extension below but with step increments rather than min or max quantities.
http://www.opencart.com/index.php?route ... um/maximum


Posts

Joined
Mon Oct 27, 2014 3:00 pm

Post by Qphoria » Mon Nov 10, 2014 10:08 pm

oh so you mean 6 of one type of product? so if they add a wine bottle to the cart, they must add 5 more of any type of wine, mix and match.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by groundcreative » Tue Nov 11, 2014 8:45 am

Yes exactly!.. any ideas or suggestions???


Posts

Joined
Mon Oct 27, 2014 3:00 pm

Post by rickky68 » Sun Mar 29, 2020 2:57 pm

The reported extensions do not solve the above mentioned problem (issue is though we want the customers to be able to choose multiple products to make up the six pack.
ie they could buy 2 of product A, 3 of product B & 1 of product C.)
do you know solution?
Thanks for the attention

Newbie

Posts

Joined
Thu Feb 09, 2017 12:28 am

Post by straightlight » Sun Mar 29, 2020 8:54 pm

rickky68 wrote:
Sun Mar 29, 2020 2:57 pm
The reported extensions do not solve the above mentioned problem (issue is though we want the customers to be able to choose multiple products to make up the six pack.
ie they could buy 2 of product A, 3 of product B & 1 of product C.)
do you know solution?
Thanks for the attention
While I understand this forum section is for OC v1.5x releases, the following has been tested on OC v3.0.3.2 with default theme.

In catalog/controller/checkout/checkout.php file,

find:

Code: Select all

foreach ($products as $product) {
			$product_total = 0;

			foreach ($products as $product_2) {
				if ($product_2['product_id'] == $product['product_id']) {
					$product_total += $product_2['quantity'];
				}
			}

			if ($product['minimum'] > $product_total) {
				$this->response->redirect($this->url->link('checkout/cart'));
			}
		}
replace with:

Code: Select all

$error_quantity = array();
		
// Change to any value you want above 0.
$value = 6;

$this->load->model('catalog/product');

foreach ($products as $product) {
	$product_total = 0;

	foreach ($products as $product_2) {
		if ($product_2['product_id'] == $product['product_id']) {
			$product_total += $product_2['quantity'];
		}
	}

	if ($product['minimum'] > $product_total) {
		$this->response->redirect($this->url->link('checkout/cart'));
	}
	
	$product_to_categories = $this->model_catalog_product->getCategories($product['product_id']);
	
	if ($product_to_categories) {
		foreach ($product_to_categories as $p2c) {
			$p2c_data = array('category_id'		=> $p2c['category_id'],
							  'product_id'		=> $p2c['product_id']
							 );
		
			$error_quantity[$product['quantity']][json_encode($p2c_data)] = true;
		}
	}
}
		
if (!empty($value) && $error_quantity) {
	// Modify the two categories to the values you want.
	$categories = array(1, 2);
	
	$this->session->data['error_quantity'] = array();
	
	foreach ($error_quantity as $quantity => $p2cs) {
		if ($quantity < $value) {
			$p2c_data = json_decode($p2cs, true);
			
			if (!empty($p2c_data['category_id']) && in_array($p2c_data['category_id'], $categories)) {
				$this->session->data['error_quantity'][$p2c_data['product_id']] = sprintf($this->language->get('error_max_quantity'), $quantity, $value);
			}
		}
	}
}

Code: Select all

$value = 6;
and

Code: Select all

$categories = array(1, 2);
can be changed to any value above 0.

In catalog/language/en-gb/checkout/checkout.php file,

add at the bottom of the file:

Code: Select all

$_['error_max_quantity']			 = 'There are %s product(s) added on the cart. The maximum product(s) allowed are %s!';
In catalog/controller/checkout/cart.php file,

find:

Code: Select all

if ($this->config->get('config_customer_price') && !$this->customer->isLogged()) {
add above:

Code: Select all

if (!empty($this->session->data['error_quantity'])) {
				$data['error_quantity'] = $this->session->data['error_quantity'];
				
				unset ($this->session->data['error_quantity']);
			} else {
				$data['error_quantity'] = '';
			}
Then, find:

Code: Select all

'cart_id'   	=> $product['cart_id'],
add below:

Code: Select all

'product_id'	=> $product['product_id'],
In catalog/view/theme/default/template/cart/cart.twig file,

find:

Code: Select all

<span class="label label-info">{{ text_recurring_item }}</span> <small>{{ product.recurring }}</small> {% endif %}</td>
replace with:

Code: Select all

<span class="label label-info">{{ text_recurring_item }}</span> <small>{{ product.recurring }}</small> {% endif %}
				{% if error_quantity[product.product_id] %}
					<br />					
					<div class="text-danger">{{ error_quantity[product.product_id] }}</div>
				{% endif %}</td>
In catalog/controller/checkout/success.php file,

find:

Code: Select all

unset($this->session->data['totals']);
add below:

Code: Select all

if (!empty($this->session->data['error_quantity'])) {
	unset ($this->session->data['error_quantity']);
}
Then, follow this FAQ: viewtopic.php?f=134&t=215776#p718325 . This should resolved the issue.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by rickky68 » Mon Mar 30, 2020 3:35 am

it is also possible to assign two rules to two product categories.
Thanks for the attention

Newbie

Posts

Joined
Thu Feb 09, 2017 12:28 am

Post by straightlight » Mon Mar 30, 2020 10:03 am

rickky68 wrote:
Mon Mar 30, 2020 3:35 am
it is also possible to assign two rules to two product categories.
Thanks for the attention
What type of rules? More information is needed.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by rickky68 » Mon Mar 30, 2020 6:07 pm

that is, they could always buy only 6 in the wine category, 12 in the beer category.
thank you very much for your availability.
riki

Newbie

Posts

Joined
Thu Feb 09, 2017 12:28 am

Post by rickky68 » Mon Mar 30, 2020 6:09 pm

sorry!
that is, they could only buy multiples of 6 in the wine category, only multiples of 12 in the beer category.
thank you very much for your time.
riki

Newbie

Posts

Joined
Thu Feb 09, 2017 12:28 am

Post by straightlight » Mon Mar 30, 2020 6:47 pm

rickky68 wrote:
Mon Mar 30, 2020 6:09 pm
sorry!
that is, they could only buy multiples of 6 in the wine category, only multiples of 12 in the beer category.
thank you very much for your time.
riki
Custom job. Please create a new service request in the Commercial Support section of the forum or contact me directly to get this done.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Mon Mar 30, 2020 7:14 pm

I modified the checkout/checkout.php controller file steps. See if it's what you want. If not, the best course of action would be to do this as a custom job.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 3 guests