Перейти до вмісту
Пошук в
  • Детальніше...
Шукати результати, які ...
Шукати результати в ...

Recommended Posts

Здравствуйте! Как сделать закладки без регистрации? Опенкарт 2

В файле В файле \catalog\controller\account\wishlist.php

 

Закомментировал строки в начале кода:

// if (!$this->customer->isLogged()) {

//        $this->session->data['redirect'] = $this->url->link('account/wishlist', '', 'SSL');

    //        $this->response->redirect($this->url->link('account/login', '', 'SSL'));

 

Не заработало. Тогда нашел на каком то форуме совет: "заменить вот эту строку:

if ($this->customer->isLogged()) {

на эту

if (1) {

И всё вроде бы заработало, только закладки стали общими для всех покупателей :) Тестил с компьютера и с телефона с мобильным интернетом (айпи то разные). Каждый кто добавляет что-то в закладки отображается общим списком для всех. Помогите пожалуйста!!!

 

Ещё нашел но проблему не решает:

<?xml version="1.0" encoding="UTF-8"?>
<modification>
    <id>Wishlist w/o Registration</id>
    <version>1.0.0</version>
    <vqmver>2.5.1</vqmver>
    <author>NZXT.UA - [email protected]</author>

    <file path="catalog/controller/account/" name="wishlist.php">

        <operation>
            <search position="replace" offset="4">
                <![CDATA[
                    if (!$this->customer->isLogged()) {
                ]]></search>
            <add>
                <![CDATA[]]>
            </add>
        </operation>

        <operation>
            <search position="replace">
                <![CDATA[
                    $data['continue'] = $this->url->link('account/account', '', 'SSL');
                ]]>
            </search>
            <add>
                <![CDATA[
                    $data['continue'] = $this->url->link('common/home');
                ]]>
            </add>
        </operation>

        <operation>
            <search position="replace">
                <![CDATA[
                    $json['info'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'), $this->url->link('product/product', 'product_id=' . (int)$this->request->post['product_id']), $product_info['name'], $this->url->link('account/wishlist'));
                ]]></search>
            <add>
                <![CDATA[
                    $json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']), $product_info['name'], $this->url->link('account/wishlist'));
                ]]>
            </add>
        </operation>

    </file>
    
</modification>

 

Ещё вариантик:

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Wishlist w/o Registration</name>
    <code>wishlist_w_o_registration</code>
    <version>1.0.0</version>    
    <author>rewuxiin</author>

    <file path="catalog/controller/account/wishlist.php">

        <operation>
            <search>
                <![CDATA[if (!$this->customer->isLogged()) {]]>
            </search>
            <add position="replace" offset="5">
                <![CDATA[]]>
            </add>
        </operation>

        <operation>
            <search>
                <![CDATA[                    
                    $data['continue'] = $this->url->link('account/account', '', 'SSL');
                ]]>
            </search>
            <add position="replace">
                <![CDATA[
                    $data['continue'] = $this->url->link('common/home');
                ]]>
            </add>
        </operation>      
        
        <operation>
            <search>
                <![CDATA[if ($this->customer->isLogged()) {]]></search>
                
            <add position="after" offset="21">
                <![CDATA[
                $this->load->model('account/wishlist');

                $this->model_account_wishlist->addWishlist($this->request->post['product_id']);

                $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'));

                $json['total'] = sprintf($this->language->get('text_wishlist'), $this->model_account_wishlist->getTotalWishlist());
                ]]>
            </add>
        </operation>

    </file>
    
</modification>
Змінено користувачем Krol
Надіслати
Поділитися на інших сайтах


закладки стали общими для всех покупателей

Ну, это вполне предсказуемо: вишлист привязывается в базе к id покупателя (посмотрите /catalog/model/account/wishlist.php), а у вас вместо него получается null (общий для всех незалогиненных).

 

Вам нужно генерировать какой-то уникальный ключ для каждого посетителя, писать его в куки (а лучше в localStorage) и в базу вместо $this->customer->getId(), если пользователь не залогинен. Соответственно, по этому ключу и определять, кому какой вишлист выводить.

 

А вообще, вроде, для этого есть модули.

Змінено користувачем Dotrox
Надіслати
Поділитися на інших сайтах


  • 3 months later...
  • 1 year later...
В 11.04.2017 в 11:40, lextorg сказал:

ocStore 2.3.0.2.3 Не обновляется число количество закладок в меню "Мои закладки" (2) вверху, а в админке, когда настраиваю, выдаёт  "Warning! You have installed a incompatible version of module for this opencart ..."  Кто нибудь чинил?

Надіслати
Поділитися на інших сайтах


  • 10 months later...

Может кому пригодится делаем закладки с регистрацией и без регистрации на примере 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'));

 

  • +1 3
Надіслати
Поділитися на інших сайтах

  • 1 month later...
3 часа назад, Espresso.Doktor сказал:

А есть возможность в OC 2.3, увидеть из админки товары которые добавили в закладки?

Из коробки такой возможности нет даже для вишлистов зарегистрированных.

Надіслати
Поділитися на інших сайтах


  • 2 months later...
В 17.06.2019 в 18:05, Dotrox сказал:

Из коробки такой возможности нет даже для вишлистов зарегистрированных.

Это почему?

1. Заходим в админку.

2. АдминПанель -> Покупатели -> Покупатели -> Войти в магазин от имени покупателя.

3. Сморим его wishlist.

 

P.S.    ХМ... но это только для одного покупателя, а если статистику смотреть по всем товарам, то этот модуль, предложенный выше.

Змінено користувачем Lilya
Надіслати
Поділитися на інших сайтах


В 17.06.2019 в 14:05, Espresso.Doktor сказал:

А есть возможность в OC 2.3, увидеть из админки товары которые добавили в закладки?

 

Устанавливайте пока бесплатный

 

Надіслати
Поділитися на інших сайтах

В 25.04.2019 в 15:27, legioner26 сказал:

Может кому пригодится делаем закладки с регистрацией и без регистрации на примере Opencart 2.3, OcStore 2.3

Код написанный мною, можете юзать )))

Походу код с багом....

Вот в этой строке:

 unset($this->session->data['wishlist'][array_search($this->request->get['remove_session'],$this->session->data['wishlist'])]);

Выбивает ошибку:

Syntax error, unexpected T_UNSET

:wacko:

Надіслати
Поділитися на інших сайтах


  • 4 weeks later...
  • 4 months later...
В 25.04.2019 в 15:27, legioner26 сказал:

Может кому пригодится делаем закладки с регистрацией и без регистрации на примере 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'));

 

Рабочий вариант, всё завелось с первого раза, спасибо.

Надіслати
Поділитися на інших сайтах


  • 6 months later...
Спойлер
В 25.04.2019 в 15:27, legioner26 сказал:

Может кому пригодится делаем закладки с регистрацией и без регистрации на примере 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'));

 

 

 

На странице закладок ошибка выскочила

No Width/Height Settings... Did you configure your image sizes?

Понимаю, что надо прописать размер на фото, но не понимаю где прописывать...

============================

Сам и отвечу ))
В контроллере закладок

Это

if ($product_info) {
				if ($product_info['image']) {
					$image = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_wishlist_width'), $this->config->get('config_image_wishlist_height'));
				} else {
					$image = false;
				}

заменить на это

				if ($product_info) {
                 if ($product_info['image']) {
						$image = $this->model_tool_image->resize($product_info['image'], 50, 50);
				} else {
					$image = false;
				}

 

Змінено користувачем Allaur
Надіслати
Поділитися на інших сайтах


  • 2 months later...

Действительно работает. Только при добавлении закладок и регистрации нового пользователя закладки аннулируются. Сохраняются только в случае, если пользователь есть базе, т.е зарегистрирован.

Надіслати
Поділитися на інших сайтах


  • 1 month later...

Для ocStore 3 не сработало, ошибка:

Notice: Undefined index: wishlist in D:\Denver\OpenServer\domains\stamp.ru\catalog\controller\account\wishlist.php on line 119Warning: Invalid argument supplied for foreach() in D:\Denver\OpenServer\domains\stamp.ru\catalog\controller\account\wishlist.php on line 121

 

Надіслати
Поділитися на інших сайтах


  • 3 months later...
В 25.04.2019 в 19:27, legioner26 сказал:

Может кому пригодится делаем закладки с регистрацией и без регистрации на примере 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'));

 

 

Если в закладках ничего не добавлено, и зайти просто в сайт.ру/wishlist/

 

появляется ошибка. Не подскажите как убрать ошибку ? 

 

Notice: Undefined index: wishlist in /var/www/www-root/data/www/сайт/catalog/controller/account/wishlist.php on line 139Warning: Invalid argument supplied for foreach() in /var/www/www-root/data/www/сайт/catalog/controller/account/wishlist.php on line 144

 

Надіслати
Поділитися на інших сайтах


В 11.02.2020 в 17:10, docjers сказал:

Рабочий вариант, всё завелось с первого раза, спасибо.

а если зайти в сайт.ру/wishlist/ без добавления в закладки, ошибки нет? 

Надіслати
Поділитися на інших сайтах


2 минуты назад, igorfelix сказал:

а если зайти в сайт.ру/wishlist/ без добавления в закладки, ошибки нет? 

 

  • +1 1
Надіслати
Поділитися на інших сайтах

  • 8 months later...
В 18.04.2021 в 14:38, igorfelix сказал:

 

Спасибо огромное. вернул базовый файл, установил этот модуль и все заработало сразу ! 

Спс Бро!

Надіслати
Поділитися на інших сайтах


Створіть аккаунт або увійдіть для коментування

Ви повинні бути користувачем, щоб залишити коментар

Створити обліковий запис

Зареєструйтеся для отримання облікового запису. Це просто!

Зареєструвати аккаунт

Вхід

Уже зареєстровані? Увійдіть тут.

Вхід зараз

×
×
  • Створити...

Important Information

На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність.