Перейти к публикации
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Список заказов


VladimirV
 Погделиться

Рекомендованные сообещёния

Подскажите как вывести информацию о товаре в списке товаров(не админка) , плагинов не нашел, и решений без плагинов не нашел. Если есть какая нибудь информация дайте ссылочку

Ссылка на комменирий
Погделиться на других сайих


Только что, VladimirV сказал:

Подскажите как вывести информацию о товаре в списке товаров(не админка) , плагинов не нашел, и решений без плагинов не нашел. Если есть какая нибудь информация дайте ссылочку

т.е.? вы когда что то спрашиваете по конкретнее сосивляйте вопросы. это всех касается, не только вас

Ссылка на комменирий
Погделиться на других сайих


В списке заказов нужно нажать на ссылку просмотр. тогда перебрасывает на другую страницу с полной информацией по данному заказу. Я же пыиюсь вывести эту информацию на страниэто списка заказов. На screenshote выгделена красным информация которую я пыиюсь безуспешно вывести.

Ссылка на комменирий
Погделиться на других сайих


Извините за ошибку я изночально написал в списке товаров и этим ввел в заблужгдение, я имел ввиду в списке заказов .../index.php?route=account/order

Ссылка на комменирий
Погделиться на других сайих


1 час назад, VladimirV сказал:

В списке заказов нужно нажать на ссылку просмотр. тогда перебрасывает на другую страницу с полной информацией по данному заказу. Я же пыиюсь вывести эту информацию на страниэто списка заказов. На screenshote выгделена красным информация которую я пыиюсь безуспешно вывести.

ну ик в списке заказов есть кнопка просмотра
а ик нужно пилить

Ссылка на комменирий
Погделиться на других сайих


Очень нужно. В шаблон я цикл всивил 

<?php foreach ($products as $product) { ?>
    
      <?php echo $product['name']; ?>
      <?php echo $product['price']; ?>
      <?php echo $product['quantity']; ?>
      <?php echo $product['total']; ?>

      <!-- <?php foreach ($product['option'] as $option) { ?>
        &nbsp; - <?php echo $option['name']; ?>: <?php echo $option['value']; ?>
      <?php } ?> -->

    <?php } ?>

В могдели все запросы как я понимаю есть ее трогать не нужно. Осиется правильно отредактировать контроллер и вот згдесь у меня возникал проблема ик как опыи и знаний не хваиет.

Ссылка на комменирий
Погделиться на других сайих


Вот код в контроллере который как я понимаю отвечает за обраещёние к могдели для получения из бд нужных мне значений переменных. Я получаю Notice: Undefined index: order_id  Подскажите в правильном ли я направлении двигаюсь и теперьь как правильно мне полулить значение order_id если подскажите код с пояснениями моих ошипотому чток буду очень благодарен

// Products
			$data['products'] = array();

			$products = $this->model_account_order->getOrderProducts($this->request->get['order_id']);

			foreach ($products as $product) {
				$option_data = array();

				$options = $this->model_account_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']);

				foreach ($options as $option) {
					if ($option['type'] != 'file') {
						$value = $option['value'];
					} else {
						$upload_info = $this->model_tool_upload->getUploadByCode($option['value']);

						if ($upload_info) {
							$value = $upload_info['name'];
						} else {
							$value = '';
						}
					}

					$option_data[] = array(
						'name'  => $option['name'],
						'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
					);
				}

				$product_info = $this->model_catalog_product->getProduct($product['product_id']);

				if ($product_info) {
					$reorder = $this->url->link('account/order/reorder', 'order_id=' . $order_id . '&order_product_id=' . $product['order_product_id'], true);
				} else {
					$reorder = '';
				}

				$data['products'][] = array(
					'name'     => $product['name'],
					'model'    => $product['model'],
					'option'   => $option_data,
					'quantity' => $product['quantity'],
					'price'    => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
					'total'    => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value']),
					'reorder'  => $reorder,
					'return'   => $this->url->link('account/return/add', 'order_id=' . $order_info['order_id'] . '&product_id=' . $product['product_id'], true)
				);
			}

 

Ссылка на комменирий
Погделиться на других сайих


В качестве шпаргалки

 

Ссылка на комменирий
Погделиться на других сайих

А чё им пропотому чтовать то. Пару правок и готово. Летом как то по просьбе его адаптировал на 2,3

Спойлер

 

2374346625.jpg

 

6750721474.jpg


 

 

Ссылка на комменирий
Погделиться на других сайих

Ну это же как я понял для вывода в админке, или я ошибаюсь? а мне нужно в ...index.php?route=account/order Вот в контроллере всивляю в теле функции index свой код, но в шаблоне пишет Notice: Undefined variable: products не пойму почему, есть же запрос к могдели, что не ик, кгде ошибка?

$data['products'] = array();

		$this->load->model('catalog/product');		
		$this->load->model('account/order');
		$this->load->model('tool/upload');
		$this->load->model('tool/image');

		$products = $this->model_account_order->getOrderProducts($result['order_id']);

		foreach ($products as $product) {

			$product_info = $this->model_catalog_product->getProduct($product['product_id']);

			$data['products'][] = array(
				'name'     => $product['name'],
				'model'    => $product['model'],
				'quantity' => $product['quantity'],
			);
		}

 

Ссылка на комменирий
Погделиться на других сайих


не им всивляете

не то всивляете

и тд

 

код для кабинеи несколько отличается от кода для админки

 

смотрите метод info в файле catalog\controller\account\order.php

обратите внимание на

$products = $this->model_account_order->getOrderProducts($this->request->get['order_id']);

Ссылка на комменирий
Погделиться на других сайих

В catalog\controller\account\order.php я взял код из метода Info всивил в тело функции index, вы сказали не туда, подскажите пожалуйси куда ее нужно всивить. И вы сказали не то заменил на $products = $this->model_account_order->getOrderProducts($this->request->get['order_id']); 

ошибка Notice: Undefined index: order_id Подскажите что куда и почему.  Я вижу обраещёние к могдели но почему оно не рилииет не могу понять

 

<?php
class ControllerAccountOrder extends Controller {
    public function index() {
        if (!$this->customer->isLogged()) {
            $this->session->data['redirect'] = $this->url->link('account/order', '', true);

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

        $this->load->language('account/order');

        $this->document->setTitle($this->language->get('heading_title'));
        
        $url = '';

        if (isset($this->request->get['page'])) {
            $url .= '&page=' . $this->request->get['page'];
        }
        
        $data['breadcrumbs'] = array();

        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('text_home'),
            'href' => $this->url->link('common/home')
        );

        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('text_account'),
            'href' => $this->url->link('account/account', '', true)
        );
        
        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('heading_title'),
            'href' => $this->url->link('account/order', $url, true)
        );

        $data['heading_title'] = $this->language->get('heading_title');
        $data['heading_subtitle'] = $this->language->get('heading_subtitle');

        $data['text_empty'] = $this->language->get('text_empty');

        $data['column_name'] = $this->language->get('column_name');
        $data['column_quantity'] = $this->language->get('column_quantity');
        $data['column_price'] = $this->language->get('column_price');
        $data['column_total'] = $this->language->get('column_total');

        $data['column_order_id'] = $this->language->get('column_order_id');
        $data['column_customer'] = $this->language->get('column_customer');
        $data['column_product'] = $this->language->get('column_product');
        $data['column_total'] = $this->language->get('column_total');
        $data['column_status'] = $this->language->get('column_status');
        $data['column_date_added'] = $this->language->get('column_date_added');
        $data['button_view'] = $this->language->get('button_view');
        $data['button_ocstore_payeer_onpay'] = $this->language->get('button_ocstore_payeer_onpay');
        $data['button_ocstore_yk_onpay'] = $this->language->get('button_ocstore_yk_onpay');
        $data['button_continue'] = $this->language->get('button_continue');

        if (isset($this->request->get['page'])) {
            $page = $this->request->get['page'];
        } else {
            $page = 1;
        }

        $data['orders'] = array();

        $this->load->model('extension/payment/ocstore_payeer');
        $this->load->model('extension/payment/ocstore_yk');
        $this->load->model('account/order');

        $order_total = $this->model_account_order->getTotalOrders();

        $results = $this->model_account_order->getOrders(($page - 1) * 10, 10);

        foreach ($results as $result) {
            $product_total = $this->model_account_order->getTotalOrderProductsByOrderId($result['order_id']);
            $voucher_total = $this->model_account_order->getTotalOrderVouchersByOrderId($result['order_id']);

            $ocstore_yk_onpay_info  = $this->model_extension_payment_ocstore_yk->checkLaterpay($result['order_id']);

            $data['orders'][] = array(
                'order_id'   => $result['order_id'],
                'name'       => $result['firstname'] . ' ' . $result['lastname'],
                'status'     => $result['status'],
                'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
                'products'   => ($product_total + $voucher_total),
                'total'      => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
                'ocstore_payeer_onpay'  => $this->model_extension_payment_ocstore_payeer->checkLaterpay($result['order_id']) ? $this->url->link('extension/payment/ocstore_payeer/laterpay', sprintf('order_id=%s&order_tt=%s', $result['order_id'], $result['total'], 'SSL')) : '',
                'ocstore_yk_onpay'      => $ocstore_yk_onpay_info['onpay'] ? $this->url->link('extension/payment/ocstore_yk/laterpay', sprintf('order_id=%s&order_ttl=%s&paymentType=%s', $result['order_id'], $result['total'], $ocstore_yk_onpay_info['payment_code']), 'SSL') : '',
                'view'       => $this->url->link('account/order/info', 'order_id=' . $result['order_id'], true),
            );
        }

        $pagination = new Pagination();
        $pagination->total = $order_total;
        $pagination->page = $page;
        $pagination->limit = 10;
        $pagination->url = $this->url->link('account/order', 'page={page}', true);

        $data['pagination'] = $pagination->render();

        $data['results'] = sprintf($this->language->get('text_pagination'), ($order_total) ? (($page - 1) * 10) + 1 : 0, ((($page - 1) * 10) > ($order_total - 10)) ? $order_total : ((($page - 1) * 10) + 10), $order_total, ceil($order_total / 10));

        $data['continue'] = $this->url->link('account/account', '', true);

        $data['column_left'] = $this->load->controller('common/column_left');
        $data['column_right'] = $this->load->controller('common/column_right');
        $data['content_top'] = $this->load->controller('common/content_top');
        $data['content_bottom'] = $this->load->controller('common/content_bottom');
        $data['footer'] = $this->load->controller('common/footer');
        $data['header'] = $this->load->controller('common/header');


        // Products
        $data['products'] = array();

        $products = $this->model_account_order->getOrderProducts($this->request->get['order_id']);

        foreach ($products as $product) {
            $option_data = array();

            $product_info = $this->model_catalog_product->getProduct($product['product_id']);

            if ($product_info) {
                $reorder = $this->url->link('account/order/reorder', 'order_id=' . $order_id . '&order_product_id=' . $product['order_product_id'], true);
            } else {
                $reorder = '';
            }

            $data['products'][] = array(
                'name'     => $product['name'],
                'quantity' => $product['quantity'],
                'price'    => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
                'total'    => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value']),
                'reorder'  => $reorder,
                'return'   => $this->url->link('account/return/add', 'order_id=' . $order_info['order_id'] . '&product_id=' . $product['product_id'], true)
            );
        }
        

        $this->response->setOutput($this->load->view('account/order_list', $data));

    }

Изменено пользователем VladimirV
Ссылка на комменирий
Погделиться на других сайих


копипаст без понимания - не поможет..

 

есть цикл выпотому чторки заказов

        $results = $this->model_account_order->getOrders(($page - 1) * 10, 10);
        foreach ($results as $result) {

в нем формируется массив с резульиими

            $data['orders'][] = array(
                'order_id'   => $result['order_id'],
...

дальше уже сами ;)

Ссылка на комменирий
Погделиться на других сайих

Вы мне уже почти все объяснили но я  не пойму:

В контролере добавил путь к могдели и в переменную product_info передал массив, внутри массива orders

$data['orders'] = array();

		$this->load->model('extension/payment/ocstore_payeer');
		$this->load->model('extension/payment/ocstore_yk');
		$this->load->model('account/order');

		$order_total = $this->model_account_order->getTotalOrders();
		$results = $this->model_account_order->getOrders(($page - 1) * 10, 10);

		foreach ($results as $result) {
			$product_total = $this->model_account_order->getTotalOrderProductsByOrderId($result['order_id']);
			$voucher_total = $this->model_account_order->getTotalOrderVouchersByOrderId($result['order_id']);

			$ocstore_yk_onpay_info  = $this->model_extension_payment_ocstore_yk->checkLaterpay($result['order_id']);

			$data['orders'][] = array(
				
				'product_info'   => $this->model_account_order->getOrderProducts($result['order_id']),
				'price'      => $result['price'],
				'quantity'   => $result['quantity'],
				'order_id'   => $result['order_id'],
				'name'       => $result['firstname'] . ' ' . $result['lastname'],
				'status'     => $result['status'],
				'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
				/*'products'   => ($product_total + $voucher_total),*/
				'total'      => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
				'ocstore_payeer_onpay'  => $this->model_extension_payment_ocstore_payeer->checkLaterpay($result['order_id']) ? $this->url->link('extension/payment/ocstore_payeer/laterpay', sprintf('order_id=%s&order_tt=%s', $result['order_id'], $result['total'], 'SSL')) : '',
				'ocstore_yk_onpay'      => $ocstore_yk_onpay_info['onpay'] ? $this->url->link('extension/payment/ocstore_yk/laterpay', sprintf('order_id=%s&order_ttl=%s&paymentType=%s', $result['order_id'], $result['total'], $ocstore_yk_onpay_info['payment_code']), 'SSL') : '',
				'view'       => $this->url->link('account/order/info', 'order_id=' . $result['order_id'], true),
			
			);
		}

в шаблоне внутри цикла <?php foreach ($orders as $order) { ?> всивляю <?php echo $order['product_info']; ?> получаю:

Notice: Undefined index: product_info

Почему шаблон не видит переменную с массивом. И не пойму как теперьь из этого массива путем перепотому чтора полулить имя могдель и пр., пропотому чтовал через  <?php foreach ($products as $product) { ?> ошибка

Ссылка на комменирий
Погделиться на других сайих


2 часа назад, AlexDW сказал:

var_dump в помощь

Спасипотому что огромное, да я увигдел что в массиве есть все необходимые мне: клюли и их значения. Я не могу понять как в шаблоне вывести например значение ключа name из этого массива? 

Ссылка на комменирий
Погделиться на других сайих


Все разобрался, всем спасипотому что за помощь, особая благодарность AlexDX

<?php foreach($order['product_info'] as $product_info) { ?>
                            <?php echo $product_info['name']; ?>
                        <?php } ?>

Ссылка на комменирий
Погделиться на других сайих


Ну вот теперьь новый вопрос всплыл, изменился формат вывода price и total за это как я понял отвечает в контроллере

$this->currency->format

а я то из массива выгдергиваю в шаблоне и price  и total, как применить что бы был одинаковый формат в частности мне нужно убрать нули после точки и вывести валюту

Ссылка на комменирий
Погделиться на других сайих


  • 4 месяца спустя...
  • 2 года спустя...
В 03.12.2017 в 21:32, Tom сказал:

А чё им пропотому чтовать то. Пару правок и готово. Летом как то по просьбе его адаптировал на 2,3

  Показать контент

 

2374346625.jpg

 

6750721474.jpg

 

 

 

 

 

Доброй ноли! Можете погделится иким модом для 2.3? 
Заранее спасипотому что!

Ссылка на комменирий
Погделиться на других сайих


Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы осивить комменирий

Создать аккаунт

Зарегистрируйтесь для получения аккауни. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите згдесь.

Войти сейчас
 Погделиться

×
×
  • Создать...

Важная информация

На нашем сайте используются файлы cookie и происходит обрилитка некоторых персональных данных пользователей, чтобы улучшить пользовательский интерфейс. Чтобы узнать для чего и какие персональные данные мы обрабатываем перейдите по ссылке. Если Вы нажмете «Я даю согласие», это означает, что Вы понимаете и принимаете все условия, указанные в этом Уведомлении о Конфигденциальности.