Which OC version are you using?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Based on your first post, what happens if you'd like to restrict the product so the product can be viewed once but the customer is also a guest customer?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Then, it is cart based - not from the list/grid product page. The subject of your topic has the wrong analogy. A tweak to accomplish this would be by editing your system/library/cart/cart.php file.
Find:
add above:
Then, in your catalog/controller/checkout/cart.php file,
find:
add below:
Then, find:
replace with:
In your catalog/language/<your_language_code>/checkout/cart.php file,
add at the bottom:
Then, in your catalog/view/javascript/common.js file,
in the:
section, find:
add above:
Then, in the
find:
add above:
This should provide what you need.
Find:
Code: Select all
public function hasProducts() {
Code: Select all
public function hasProduct($product_id) {
$products = $this->getProducts();
foreach ($products as $product) {
if ((int)$product_id == (int)$product['product_id']) {
return true;
}
}
}
find:
Code: Select all
if (isset($this->request->post['quantity'])) {
$quantity = (int)$this->request->post['quantity'];
} else {
$quantity = 1;
}
Code: Select all
if ($this->cart->hasProduct($product_info['product_id'])) {
$json['error']['same_product'] = sprintf($this->language->get('text_same_product'), html_entity_decode($product_info['name'], ENT_QUOTES, 'UTF-8'));
}
Code: Select all
foreach ($this->request->post['quantity'] as $key => $value) {
$this->cart->update($key, $value);
}
Code: Select all
$this->load->model('catalog/product');
foreach ($this->request->post['quantity'] as $key => $value) {
$product_info = $this->model_catalog_product->getProduct($key);
if ($product_info && $this->cart->hasProduct($product_info['product_id'])) {
$json['error']['same_product'] = $this->language->get('text_same_product');
}
}
add at the bottom:
Code: Select all
$_['text_same_product'] = 'The product name: %s has already been added to your cart.';
in the:
Code: Select all
var cart = {
Code: Select all
if (json['redirect']) {
Code: Select all
if (json['error']['same_product']) {
$('#content').parent().before('<div class="alert alert-danger alert-dismissible">' + json['error']['same_product'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
}
Code: Select all
'update': function(key, quantity) {
Code: Select all
if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
Code: Select all
if (json['error']['same_product']) {
$('#content').parent().before('<div class="alert alert-danger alert-dismissible">' + json['error']['same_product'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: No registered users and 16 guests