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

Как сделать вывод описания товара в корзине cart.tpl?


Recommended Posts

Здравствуйте.

Стандартная корзина выводит только название товара, в моем случае - это пицца.

Но вывод описания не работает, я понимаю, что в дело в контроллере.

Описание в cart.tpl я сделал вставку кода 

 

<td class="text-left"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>

                  <?php if (!$product['stock']) { ?>
                  <span class="text-danger">***</span>
                  <?php } ?>
                  <?php if ($product['option']) { ?>
                  <?php foreach ($product['option'] as $option) { ?>
                  <br />
                  <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
                  <?php } ?>
                  <?php } ?>
                  <?php if ($product['reward']) { ?>
                  <br />
                  <small><?php echo $product['reward']; ?></small>
                  <?php } ?>
                  <?php if ($product['recurring']) { ?>
                  <br />
                  <span class="label label-info"><?php echo $text_recurring_item; ?></span> <small><?php echo $product['recurring']; ?></small>
                  <?php } ?>
                </td>

что мне нужно в контроллере сделать?

ибо пишет 

post-697157-0-16279200-1459500600_thumb.png

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


далее я сделал вставку в cart.php в контроллере 

 

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

'key'       => $product['key'],
'thumb'     => $image,
'name'      => $product['name'],
'model'     => $product['model'],
'option'    => $option_data,
'recurring' => $recurring,
'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
'quantity'  => $product['quantity'],
'stock'     => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
'reward'    => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
'price'     => $price,
'total'     => $total,
'href'      => $this->url->link('product/product', 'product_id=' . $product['product_id'])
);

'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..', вот эту строку 

помогите пожалуйста разобраться 

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


А где тут description?

действительно вы правы, я поправил, но не появилось . . .

ругается теперь конкретно на <p><?php echo $product['description']; ?></p> эту вот строчку

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


действительно вы правы, я поправил, но не появилось . . .

ругается теперь конкретно на <p><?php echo $product['description']; ?></p> эту вот строчку

В контроллере у вас $data['products'] ...

В шаблоне обращаетесь $product

 

Скиньте весь код, чтобы понять лучше

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

и теперь выводится лишь многоточие "<p>..</p>"

Если ошибки пропали и выводиться многоточие то посмотрите что у вас здесь

 

 

 

utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length'))
Надіслати
Поділитися на інших сайтах

<?php echo $header; ?>
</div>
</div>
</div>
<div class="contair-fluid" style="background: #f3e7d4">
<div class="container">
  <div class="row"><?php echo $column_left; ?>
    <?php if ($column_left && $column_right) { ?>
    <?php $class = 'col-sm-6'; ?>
    <?php } elseif ($column_left || $column_right) { ?>
    <?php $class = 'col-sm-9'; ?>
    <?php } else { ?>
    <?php $class = 'col-sm-12'; ?>
    <?php } ?>
    <div id="content" class="<?php echo $class; ?>"><?php echo $content_top; ?>
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
        <div class="table cart-page">
          <table class="table table-bordered">
            <tbody>
              <?php foreach ($products as $product) { ?>
              <tr>
                <td class="text-center"><?php if ($product['thumb']) { ?>
                  <a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-thumbnail" /></a>
                  <?php } ?></td>
                <td class="text-left"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
                  <?php if (!$product['stock']) { ?>
                  <span class="text-danger">***</span>
                  <?php } ?>
                  <p><?php echo $product['description']; ?></p>
                  <?php if ($product['option']) { ?>
                  <?php foreach ($product['option'] as $option) { ?>
                  <br />
                  <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
                  <?php } ?>
                  <?php } ?>
                  <?php if ($product['reward']) { ?>
                  <br />
                  <small><?php echo $product['reward']; ?></small>
                  <?php } ?>
                  <?php if ($product['recurring']) { ?>
                  <br />
                  <span class="label label-info"><?php echo $text_recurring_item; ?></span> <small><?php echo $product['recurring']; ?></small>
                  <?php } ?>
                </td>
                <td class="text-left"><div class="input-group btn-block" style="max-width: 130px; height: 40px">
                    <span class="input-group-addon "><span class="glyphicon glyphicon-chevron-left"></span></span>
                    <input type="text" name="quantity[<?php echo $product['key']; ?>]" value="<?php echo $product['quantity']; ?>" size="1" class="form-control" />
                    <span class="input-group-addon right-counter-plus"><span class="glyphicon glyphicon-chevron-right"></span></span>
                    <span class="input-group-btn"></span></div>
                    <p class="price-and-total">x <?php echo $product['price']; ?></br>
                    <strong>= <?php echo $product['total']; ?></strong></p>
                </td>
                <td><button type="submit" data-toggle="tooltip" title="<?php echo $button_update; ?>" class="glyphicon glyphicon-refresh nobg"><i class="fa fa-refresh"></i></button></td>
                <td><button type="button" data-toggle="tooltip" title="<?php echo $button_remove; ?>" class="glyphicon glyphicon-remove nobg" onclick="cart.remove('<?php echo $product['key']; ?>');"><i class="fa fa-times-circle"></i></button></span></div>
                </td>
              </tr>
              <?php } ?>
            </tbody>
          </table>
        </div>
      </form>
      <div class="row">
        <div class="col-sm-4 col-sm-offset-8">
            <?php foreach ($totals as $total) { ?>
              <strong><?php echo $total['title']; ?>:</strong>
              <?php echo $total['text']; ?>
            <?php } ?>
        </div>
      </div>
      <div class="buttons">
        <div class="pull-right"><a href="<?php echo $checkout; ?>" class="btn btn-primary btn_oformit"><?php echo $button_checkout; ?></a></div>
      </div>
      </div>
      </div>
      </div>
      <div class="container-fluid" style="background: white;">
        <div class="container">
          <div class="shema">
            <div class="col-md-3 rab">
                <img src="catalog/view/theme/je/images/icon_poc.png" alt="">
                <a href="#">Как сделать заказ</a>
                <div>Поиск и выбор блюда</div>
            </div>
            <div class="col-md-3 rab">
                <img src="catalog/view/theme/je/images/icon_price.png" alt="">
                <a href="#">Как оплатить заказ</a>
                <div>Способ оплаты</div>
            </div>
            <div class="col-md-3 rab">
                <img src="catalog/view/theme/je/images/icon_auto.png" alt="">
                <a href="#">Доставка</a>
                <div>Способы и сроки доставки</div>
            </div>
          </div>
        </div>
      </div>
      <?php echo $content_bottom; ?></div>
    <?php echo $column_right; ?></div>
</div>
<?php echo $footer; ?>

Это cart.tpl

Ошибку пишет  на эту строчку 'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',

 

а вот cart.php

<?php
class ControllerCheckoutCart extends Controller {
	public function index() {
		$this->load->language('checkout/cart');

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

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

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

		$data['breadcrumbs'][] = array(
			'href' => $this->url->link('checkout/cart'),
			'text' => $this->language->get('heading_title')
		);

		if ($this->cart->hasProducts() || !empty($this->session->data['vouchers'])) {
			$data['heading_title'] = $this->language->get('heading_title');

			$data['text_recurring_item'] = $this->language->get('text_recurring_item');
			$data['text_next'] = $this->language->get('text_next');
			$data['text_next_choice'] = $this->language->get('text_next_choice');

			$data['column_image'] = $this->language->get('column_image');
			$data['column_name'] = $this->language->get('column_name');
			$data['column_model'] = $this->language->get('column_model');
			$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['button_update'] = $this->language->get('button_update');
			$data['button_remove'] = $this->language->get('button_remove');
			$data['button_shopping'] = $this->language->get('button_shopping');
			$data['button_checkout'] = $this->language->get('button_checkout');

			if (!$this->cart->hasStock() && (!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning'))) {
				$data['error_warning'] = $this->language->get('error_stock');
			} elseif (isset($this->session->data['error'])) {
				$data['error_warning'] = $this->session->data['error'];

				unset($this->session->data['error']);
			} else {
				$data['error_warning'] = '';
			}

			if ($this->config->get('config_customer_price') && !$this->customer->isLogged()) {
				$data['attention'] = sprintf($this->language->get('text_login'), $this->url->link('account/login'), $this->url->link('account/register'));
			} else {
				$data['attention'] = '';
			}

			if (isset($this->session->data['success'])) {
				$data['success'] = $this->session->data['success'];

				unset($this->session->data['success']);
			} else {
				$data['success'] = '';
			}

			$data['action'] = $this->url->link('checkout/cart/edit', '', true);

			if ($this->config->get('config_cart_weight')) {
				$data['weight'] = $this->weight->format($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $this->language->get('decimal_point'), $this->language->get('thousand_point'));
			} else {
				$data['weight'] = '';
			}

			$this->load->model('tool/image');
			$this->load->model('tool/upload');

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

			$products = $this->cart->getProducts();

			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) {
					$data['error_warning'] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']);
				}

				if ($product['image']) {
					$image = $this->model_tool_image->resize($product['image'], $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'));
				} else {
					$image = '';
				}

				$option_data = array();

				foreach ($product['option'] 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)
					);
				}

				// Display prices
				if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
					$price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
				} else {
					$price = false;
				}

				// Display prices
				if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
					$total = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']);
				} else {
					$total = false;
				}

				$recurring = '';

				if ($product['recurring']) {
					$frequencies = array(
						'day'        => $this->language->get('text_day'),
						'week'       => $this->language->get('text_week'),
						'semi_month' => $this->language->get('text_semi_month'),
						'month'      => $this->language->get('text_month'),
						'year'       => $this->language->get('text_year'),
					);

					if ($product['recurring']['trial']) {
						$recurring = sprintf($this->language->get('text_trial_description'), $this->currency->format($this->tax->calculate($product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['trial_cycle'], $frequencies[$product['recurring']['trial_frequency']], $product['recurring']['trial_duration']) . ' ';
					}

					if ($product['recurring']['duration']) {
						$recurring .= sprintf($this->language->get('text_payment_description'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']);
					} else {
						$recurring .= sprintf($this->language->get('text_payment_cancel'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']);
					}
				}

				$data['products'][] = array(
					'key'       => $product['key'],
					'thumb'     => $image,
					'name'      => $product['name'],
					'model'     => $product['model'],
					'option'    => $option_data,
					'recurring' => $recurring,
					'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
					'quantity'  => $product['quantity'],
					'stock'     => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
					'reward'    => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
					'price'     => $price,
					'total'     => $total,
					'href'      => $this->url->link('product/product', 'product_id=' . $product['product_id'])
				);
			}

			// Totals
			$this->load->model('extension/extension');

			$total_data = array();
			$total = 0;
			$taxes = $this->cart->getTaxes();

			// Display prices
			if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
				$sort_order = array();

				$results = $this->model_extension_extension->getExtensions('total');

				foreach ($results as $key => $value) {
					$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
				}

				array_multisort($sort_order, SORT_ASC, $results);

				foreach ($results as $result) {
					if ($this->config->get($result['code'] . '_status')) {
						$this->load->model('total/' . $result['code']);

						$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
					}
				}

				$sort_order = array();

				foreach ($total_data as $key => $value) {
					$sort_order[$key] = $value['sort_order'];
				}

				array_multisort($sort_order, SORT_ASC, $total_data);
			}

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

			foreach ($total_data as $total) {
				$data['totals'][] = array(
					'title' => $total['title'],
					'text'  => $this->currency->format($total['value'])
				);
			}

			$data['continue'] = $this->url->link('common/home');

			$data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');

			$this->load->model('extension/extension');

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

			$data['coupon'] = $this->load->controller('checkout/coupon');
			$data['voucher'] = $this->load->controller('checkout/voucher');
			$data['reward'] = $this->load->controller('checkout/reward');
			$data['shipping'] = $this->load->controller('checkout/shipping');
			$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');

			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/cart.tpl')) {
				$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/checkout/cart.tpl', $data));
			} else {
				$this->response->setOutput($this->load->view('default/template/checkout/cart.tpl', $data));
			}
		} else {
			$data['heading_title'] = $this->language->get('heading_title');

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

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

			$data['continue'] = $this->url->link('common/home');

			unset($this->session->data['success']);

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

			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
				$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/error/not_found.tpl', $data));
			} else {
				$this->response->setOutput($this->load->view('default/template/error/not_found.tpl', $data));
			}
		}
	}

	public function add() {
		$this->load->language('checkout/cart');

		$json = array();

		if (isset($this->request->post['product_id'])) {
			$product_id = (int)$this->request->post['product_id'];
		} else {
			$product_id = 0;
		}

		$this->load->model('catalog/product');

		$product_info = $this->model_catalog_product->getProduct($product_id);

		if ($product_info) {
			if (isset($this->request->post['quantity']) && ((int)$this->request->post['quantity'] >= $product_info['minimum'])) {
				$quantity = (int)$this->request->post['quantity'];
			} else {
				$quantity = $product_info['minimum'] ? $product_info['minimum'] : 1;
			}

			if (isset($this->request->post['option'])) {
				$option = array_filter($this->request->post['option']);
			} else {
				$option = array();
			}

			$product_options = $this->model_catalog_product->getProductOptions($this->request->post['product_id']);

			foreach ($product_options as $product_option) {
				if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
					$json['error']['option'][$product_option['product_option_id']] = sprintf($this->language->get('error_required'), $product_option['name']);
				}
			}

			if (isset($this->request->post['recurring_id'])) {
				$recurring_id = $this->request->post['recurring_id'];
			} else {
				$recurring_id = 0;
			}

			$recurrings = $this->model_catalog_product->getProfiles($product_info['product_id']);

			if ($recurrings) {
				$recurring_ids = array();

				foreach ($recurrings as $recurring) {
					$recurring_ids[] = $recurring['recurring_id'];
				}

				if (!in_array($recurring_id, $recurring_ids)) {
					$json['error']['recurring'] = $this->language->get('error_recurring_required');
				}
			}

			if (!$json) {
				$this->cart->add($this->request->post['product_id'], $quantity, $option, $recurring_id);

				$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('checkout/cart'));

				unset($this->session->data['shipping_method']);
				unset($this->session->data['shipping_methods']);
				unset($this->session->data['payment_method']);
				unset($this->session->data['payment_methods']);

				// Totals
				$this->load->model('extension/extension');

				$total_data = array();
				$total = 0;
				$taxes = $this->cart->getTaxes();

				// Display prices
				if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
					$sort_order = array();

					$results = $this->model_extension_extension->getExtensions('total');

					foreach ($results as $key => $value) {
						$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
					}

					array_multisort($sort_order, SORT_ASC, $results);

					foreach ($results as $result) {
						if ($this->config->get($result['code'] . '_status')) {
							$this->load->model('total/' . $result['code']);

							$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
						}
					}

					$sort_order = array();

					foreach ($total_data as $key => $value) {
						$sort_order[$key] = $value['sort_order'];
					}

					array_multisort($sort_order, SORT_ASC, $total_data);
				}

				$json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
			} else {
				$json['redirect'] = str_replace('&', '&', $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']));
			}
		}

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}

	public function edit() {
		$this->load->language('checkout/cart');

		$json = array();

		// Update
		if (!empty($this->request->post['quantity'])) {
			foreach ($this->request->post['quantity'] as $key => $value) {
				$this->cart->update($key, $value);
			}

			unset($this->session->data['shipping_method']);
			unset($this->session->data['shipping_methods']);
			unset($this->session->data['payment_method']);
			unset($this->session->data['payment_methods']);
			unset($this->session->data['reward']);

			$this->response->redirect($this->url->link('checkout/cart'));
		}

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}

	public function remove() {
		$this->load->language('checkout/cart');

		$json = array();

		// Remove
		if (isset($this->request->post['key'])) {
			$this->cart->remove($this->request->post['key']);

			unset($this->session->data['vouchers'][$this->request->post['key']]);

			$this->session->data['success'] = $this->language->get('text_remove');

			unset($this->session->data['shipping_method']);
			unset($this->session->data['shipping_methods']);
			unset($this->session->data['payment_method']);
			unset($this->session->data['payment_methods']);
			unset($this->session->data['reward']);

			// Totals
			$this->load->model('extension/extension');

			$total_data = array();
			$total = 0;
			$taxes = $this->cart->getTaxes();

			// Display prices
			if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
				$sort_order = array();

				$results = $this->model_extension_extension->getExtensions('total');

				foreach ($results as $key => $value) {
					$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
				}

				array_multisort($sort_order, SORT_ASC, $results);

				foreach ($results as $result) {
					if ($this->config->get($result['code'] . '_status')) {
						$this->load->model('total/' . $result['code']);

						$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
					}
				}

				$sort_order = array();

				foreach ($total_data as $key => $value) {
					$sort_order[$key] = $value['sort_order'];
				}

				array_multisort($sort_order, SORT_ASC, $total_data);
			}

			$json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
		}

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
}

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


В контроллере у вас $data['products'] ...

В шаблоне обращаетесь $product

 

Скиньте весь код, чтобы понять лучше

вы правы....

но мне же нужно обращаться к одному продукту. 

я тут туплю :(

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


Однако в модуле рекомендованных товаров как раз так и написано  products

и оно спокойно выводит то, что нужно нам. т.е. у каждого товара описание. 

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


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

ну или хотя бы краткое описание, но тут я думаю уже смогу без проблем ограничить кол-во символов в php.

главное сделать вывод нормальный

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


в итоге оно ругается на этот массив 


				$data['products'][] = array(
					'key'       => $product['key'],
					'thumb'     => $image,
					'name'      => $product['name'],
					'model'     => $product['model'],
					'option'    => $option_data,
					'recurring' => $recurring,
					'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
					'quantity'  => $product['quantity'],
					'stock'     => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
					'reward'    => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
					'price'     => $price,
					'total'     => $total,
					'href'      => $this->url->link('product/product', 'product_id=' . $product['product_id'])
				);

почему?

мне где-то выше стоит сделать get dicsription???

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


в итоге оно ругается на этот массив 


				$data['products'][] = array(
					'key'       => $product['key'],
					'thumb'     => $image,
					'name'      => $product['name'],
					'model'     => $product['model'],
					'option'    => $option_data,
					'recurring' => $recurring,
					'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
					'quantity'  => $product['quantity'],
					'stock'     => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
					'reward'    => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
					'price'     => $price,
					'total'     => $total,
					'href'      => $this->url->link('product/product', 'product_id=' . $product['product_id'])
				);

почему?

мне где-то выше стоит сделать get dicsription???

 

Я б Вам  помог если б Вы выложили весь код файлов под

спойлер

. Не охота отрывать чистые исходники и догадываться

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

Я б Вам  помог если б Вы выложили весь код файлов под

спойлер

. Не охота отрывать чистые исходники и догадываться

но оно стразу преобразует html в страницу и не видно кода . . . или я что то не так делаю?

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


но оно стразу преобразует html в страницу и не видно кода . . . или я что то не так делаю?

 

Пример

 

<?php
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';






$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';








$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';
$mnogo_mnogo_mnogo = 'koda';

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

class ControllerCheckoutCart extends Controller {
public function index() {
$this->load->language('checkout/cart');

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

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

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

$data['breadcrumbs'][] = array(
'href' => $this->url->link('checkout/cart'),
'text' => $this->language->get('heading_title')
);

if ($this->cart->hasProducts() || !empty($this->session->data['vouchers'])) {
$data['heading_title'] = $this->language->get('heading_title');

$data['text_recurring_item'] = $this->language->get('text_recurring_item');
$data['text_next'] = $this->language->get('text_next');
$data['text_next_choice'] = $this->language->get('text_next_choice');

$data['column_image'] = $this->language->get('column_image');
$data['column_name'] = $this->language->get('column_name');
$data['column_model'] = $this->language->get('column_model');
$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['button_update'] = $this->language->get('button_update');
$data['button_remove'] = $this->language->get('button_remove');
$data['button_shopping'] = $this->language->get('button_shopping');
$data['button_checkout'] = $this->language->get('button_checkout');

if (!$this->cart->hasStock() && (!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning'))) {
$data['error_warning'] = $this->language->get('error_stock');
} elseif (isset($this->session->data['error'])) {
$data['error_warning'] = $this->session->data['error'];

unset($this->session->data['error']);
} else {
$data['error_warning'] = '';
}

if ($this->config->get('config_customer_price') && !$this->customer->isLogged()) {
$data['attention'] = sprintf($this->language->get('text_login'), $this->url->link('account/login'), $this->url->link('account/register'));
} else {
$data['attention'] = '';
}

if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];

unset($this->session->data['success']);
} else {
$data['success'] = '';
}

$data['action'] = $this->url->link('checkout/cart/edit', '', true);

if ($this->config->get('config_cart_weight')) {
$data['weight'] = $this->weight->format($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $this->language->get('decimal_point'), $this->language->get('thousand_point'));
} else {
$data['weight'] = '';
}

$this->load->model('tool/image');
$this->load->model('tool/upload');

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

$products = $this->cart->getProducts();

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) {
$data['error_warning'] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']);
}

if ($product['image']) {
$image = $this->model_tool_image->resize($product['image'], $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'));
} else {
$image = '';
}

$option_data = array();

foreach ($product['option'] 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)
);
}

// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}

// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$total = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']);
} else {
$total = false;
}

$recurring = '';

if ($product['recurring']) {
$frequencies = array(
'day' => $this->language->get('text_day'),
'week' => $this->language->get('text_week'),
'semi_month' => $this->language->get('text_semi_month'),
'month' => $this->language->get('text_month'),
'year' => $this->language->get('text_year'),
);

if ($product['recurring']['trial']) {
$recurring = sprintf($this->language->get('text_trial_description'), $this->currency->format($this->tax->calculate($product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['trial_cycle'], $frequencies[$product['recurring']['trial_frequency']], $product['recurring']['trial_duration']) . ' ';
}

if ($product['recurring']['duration']) {
$recurring .= sprintf($this->language->get('text_payment_description'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']);
} else {
$recurring .= sprintf($this->language->get('text_payment_cancel'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']);
}
}

$data['products'][] = array(
'key' => $product['key'],
'thumb' => $image,
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'recurring' => $recurring,
/*'description' => htmlspecialchars_decode($product['description']),*/
'description' => utf8_substr(strip_tags(html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
'quantity' => $product['quantity'],
'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
'reward' => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
'price' => $price,
'total' => $total,
'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'])
);
}

// Totals
$this->load->model('extension/extension');

$total_data = array();
$total = 0;
$taxes = $this->cart->getTaxes();

// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$sort_order = array();

$results = $this->model_extension_extension->getExtensions('total');

foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
}

array_multisort($sort_order, SORT_ASC, $results);

foreach ($results as $result) {
if ($this->config->get($result['code'] . '_status')) {
$this->load->model('total/' . $result['code']);

$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
}
}

$sort_order = array();

foreach ($total_data as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}

array_multisort($sort_order, SORT_ASC, $total_data);
}

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

foreach ($total_data as $total) {
$data['totals'][] = array(
'title' => $total['title'],
'text' => $this->currency->format($total['value'])
);
}

$data['continue'] = $this->url->link('common/home');

$data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');

$this->load->model('extension/extension');

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

$data['coupon'] = $this->load->controller('checkout/coupon');
$data['voucher'] = $this->load->controller('checkout/voucher');
$data['reward'] = $this->load->controller('checkout/reward');
$data['shipping'] = $this->load->controller('checkout/shipping');
$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');

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/cart.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/checkout/cart.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/checkout/cart.tpl', $data));
}
} else {
$data['heading_title'] = $this->language->get('heading_title');

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

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

$data['continue'] = $this->url->link('common/home');

unset($this->session->data['success']);

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

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/error/not_found.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/error/not_found.tpl', $data));
}
}
}

public function add() {
$this->load->language('checkout/cart');

$json = array();

if (isset($this->request->post['product_id'])) {
$product_id = (int)$this->request->post['product_id'];
} else {
$product_id = 0;
}

$this->load->model('catalog/product');

$product_info = $this->model_catalog_product->getProduct($product_id);

if ($product_info) {
if (isset($this->request->post['quantity']) && ((int)$this->request->post['quantity'] >= $product_info['minimum'])) {
$quantity = (int)$this->request->post['quantity'];
} else {
$quantity = $product_info['minimum'] ? $product_info['minimum'] : 1;
}

if (isset($this->request->post['option'])) {
$option = array_filter($this->request->post['option']);
} else {
$option = array();
}

$product_options = $this->model_catalog_product->getProductOptions($this->request->post['product_id']);

foreach ($product_options as $product_option) {
if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
$json['error']['option'][$product_option['product_option_id']] = sprintf($this->language->get('error_required'), $product_option['name']);
}
}

if (isset($this->request->post['recurring_id'])) {
$recurring_id = $this->request->post['recurring_id'];
} else {
$recurring_id = 0;
}

$recurrings = $this->model_catalog_product->getProfiles($product_info['product_id']);

if ($recurrings) {
$recurring_ids = array();

foreach ($recurrings as $recurring) {
$recurring_ids[] = $recurring['recurring_id'];
}

if (!in_array($recurring_id, $recurring_ids)) {
$json['error']['recurring'] = $this->language->get('error_recurring_required');
}
}

if (!$json) {
$this->cart->add($this->request->post['product_id'], $quantity, $option, $recurring_id);

$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('checkout/cart'));

unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);

// Totals
$this->load->model('extension/extension');

$total_data = array();
$total = 0;
$taxes = $this->cart->getTaxes();

// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$sort_order = array();

$results = $this->model_extension_extension->getExtensions('total');

foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
}

array_multisort($sort_order, SORT_ASC, $results);

foreach ($results as $result) {
if ($this->config->get($result['code'] . '_status')) {
$this->load->model('total/' . $result['code']);

$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
}
}

$sort_order = array();

foreach ($total_data as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}

array_multisort($sort_order, SORT_ASC, $total_data);
}

$json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
} else {
$json['redirect'] = str_replace('&', '&', $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']));
}
}

$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}

public function edit() {
$this->load->language('checkout/cart');

$json = array();

// Update
if (!empty($this->request->post['quantity'])) {
foreach ($this->request->post['quantity'] as $key => $value) {
$this->cart->update($key, $value);
}

unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['reward']);

$this->response->redirect($this->url->link('checkout/cart'));
}

$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}

public function remove() {
$this->load->language('checkout/cart');

$json = array();

// Remove
if (isset($this->request->post['key'])) {
$this->cart->remove($this->request->post['key']);

unset($this->session->data['vouchers'][$this->request->post['key']]);

$this->session->data['success'] = $this->language->get('text_remove');

unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['reward']);

// Totals
$this->load->model('extension/extension');

$total_data = array();
$total = 0;
$taxes = $this->cart->getTaxes();

// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$sort_order = array();

$results = $this->model_extension_extension->getExtensions('total');

foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
}

array_multisort($sort_order, SORT_ASC, $results);

foreach ($results as $result) {
if ($this->config->get($result['code'] . '_status')) {
$this->load->model('total/' . $result['code']);

$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
}
}

$sort_order = array();

foreach ($total_data as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}

array_multisort($sort_order, SORT_ASC, $total_data);
}

$json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
}

$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}

вы правы, php код без проблем вставляет. html не хочет, да вам и не нужно . .  

это код cart.tpl + я еще сделал вставку в / library / cart.php

после строки 'name'            => $product_query->row['name'],

вставил 'description'            => $product_query->row['description'],

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


$product_info['description'] ====>  $product['description']

капельку точнее скажите, что и куда . . . 

'description' => utf8_substr(strip_tags(html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..', 

вот так на данный момент массив мой выглядит

data['products'][] = array(

'key' => $product['key'],

'thumb' => $image,

'name' => $product['name'],

'model' => $product['model'],

'option' => $option_data,

'recurring' => $recurring,

/*'description' => htmlspecialchars_decode($product['description']),*/

'description' => utf8_substr(strip_tags(html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',

'quantity' => $product['quantity'],

'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),

'reward' => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),

'price' => $price,

'total' => $total,

'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'])

);

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


Я б Вам  помог если б Вы выложили весь код файлов под

спойлер

. Не охота отрывать чистые исходники и догадываться

Я справился) спасибо, что отозвались!!!! ) 

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


вот только помимо описания, нужно еще выводить верхнюю категорию

т.е. у меня это название кафе . . . с логотипом.

каким образом это сделать?

Структура у меня идет такая

1. Все заведения 

2. Кафе Квартал

2.1 Пицца

2.2 Напитки

2.3 Десерты

 

и т.д.

и мне нужно выдрать именно Кафе Квартал?

или может кто-нибудь реализовал такое удовольствие и знает как лучше сделать структуру по другому немного

post-697157-0-07696000-1459518672_thumb.png

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


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

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

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

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

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

Вхід

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

Вхід зараз

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

Important Information

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