thanks!
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!
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
ie they could buy 2 of product A, 3 of product B & 1 of product C.
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 ?
No doesn't matter what's actually in the cart as long as the total is in multiples of six
Any suggestions???
Thanks!
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
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.rickky68 wrote: ↑Sun Mar 29, 2020 2:57 pmThe 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
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'));
}
}
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;
Code: Select all
$categories = array(1, 2);
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!';
find:
Code: Select all
if ($this->config->get('config_customer_price') && !$this->customer->isLogged()) {
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'] = '';
}
Code: Select all
'cart_id' => $product['cart_id'],
Code: Select all
'product_id' => $product['product_id'],
find:
Code: Select all
<span class="label label-info">{{ text_recurring_item }}</span> <small>{{ product.recurring }}</small> {% endif %}</td>
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>
find:
Code: Select all
unset($this->session->data['totals']);
Code: Select all
if (!empty($this->session->data['error_quantity'])) {
unset ($this->session->data['error_quantity']);
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
What type of rules? More information is needed.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Custom job. Please create a new service request in the Commercial Support section of the forum or contact me directly to get this done.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: No registered users and 26 guests