Может кому пригодится делаем закладки с регистрацией и без регистрации на примере Opencart 2.3, OcStore 2.3
Код написанный мною, можете юзать )))
Идем в контроллер закладок
Комментим проверку
class ControllerAccountWishList extends Controller {
public function index() {
/*if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/wishlist', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}*/
Далее после кода
if (isset($this->request->get['remove'])) {
// Remove Wishlist
$this->model_account_wishlist->deleteWishlist($this->request->get['remove']);
$this->session->data['success'] = $this->language->get('text_remove');
$this->response->redirect($this->url->link('account/wishlist'));
}
вставляем
if (isset($this->request->get['remove_session'])) {
// Remove Wishlist_session
unset($this->session->data['wishlist'][array_search($this->request->get['remove_session'],$this->session->data['wishlist'])]);
if (empty($this->session->data['wishlist'])) {
$this->response->redirect($this->url->link('common/home'));
}
}
Далее после
$data['products'] = array();
Вставляем
if ($this->customer->isLogged()) {
Далее после
else {
$this->model_account_wishlist->deleteWishlist($result['product_id']);
}
}
Вставляем
} else {
$results = $this->session->data['wishlist'];
foreach ($results as $key => $result) {
$product_info = $this->model_catalog_product->getProduct($result);
if ($product_info) {
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_wishlist_width'), $this->config->get($this->config->get('config_theme') . '_image_wishlist_height'));
} else {
$image = false;
}
if ($product_info['quantity'] <= 0) {
$stock = $product_info['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$stock = $product_info['quantity'];
} else {
$stock = $this->language->get('text_instock');
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
$data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'model' => $product_info['model'],
'stock' => $stock,
'price' => $price,
'special' => $special,
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
'remove' => $this->url->link('account/wishlist', 'remove_session=' . $product_info['product_id'])
);
} else {
unset($this->session->data['wishlist'][$key]);
}
}
}
Далее меняем вместо
$json['success'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true), $this->url->link('product/product', 'product_id=' . (int)$this->request->post['product_id']), $product_info['name'], $this->url->link('account/wishlist'));
Вставляем это
$json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . (int)$this->request->post['product_id']), $product_info['name'], $this->url->link('account/wishlist'));