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

Доставка в карточке товара


Recommended Posts

Как добавить строку "Доставка" под Производитель, Модель Наличие в карточке товара. Например если в в админке у товара указано не требует доставки, то в карточке выводилось "Доставка: электронно". 

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


В catalog/model/catalog/product.php

 

public function getProduct($product_id) {

'shipping'          => $query->row['shipping'],

В catalog/controller/product/product.php

 

if ($product_info) {

$data['shipping'] = $product_info['shipping'];

В каком хотим месте catalog/view/theme/default/template/product/product.tpl

if ($shipping) {
  тарам пам пам
} else {
  не тарам пам пам
}
  • +1 1
Надіслати
Поділитися на інших сайтах

В catalog/model/catalog/product.php

public function getProduct($product_id) {

'shipping'          => $query->row['shipping'],
В catalog/controller/product/product.php

if ($product_info) {

$data['shipping'] = $product_info['shipping'];
В каком хотим месте catalog/view/theme/default/template/product/product.tpl
if ($shipping) {  тарам пам пам} else {  не тарам пам пам}

Не понял как сделать в catalog/view/theme/default/template/product/product.tpl. Вот мой код:

catalog/model/catalog/product.php

class ModelCatalogProduct extends Model {

public function updateViewed($product_id) {

$this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = (viewed + 1) WHERE product_id = '" . (int)$product_id . "'");

}

public function getProduct($product_id) {

$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");

if ($query->num_rows) {

return array(

'product_id' => $query->row['product_id'],

'name' => $query->row['name'],

'description' => $query->row['description'],

'meta_title' => $query->row['meta_title'],

'meta_description' => $query->row['meta_description'],

'meta_keyword' => $query->row['meta_keyword'],

'tag' => $query->row['tag'],

'model' => $query->row['model'],

'sku' => $query->row['sku'],

'upc' => $query->row['upc'],

'ean' => $query->row['ean'],

'jan' => $query->row['jan'],

'isbn' => $query->row['isbn'],

'mpn' => $query->row['mpn'],

'location' => $query->row['location'],

'quantity' => $query->row['quantity'],

'stock_status' => $query->row['stock_status'],

'image' => $query->row['image'],

'manufacturer_id' => $query->row['manufacturer_id'],

'manufacturer' => $query->row['manufacturer'],

'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']),

'special' => $query->row['special'],

'reward' => $query->row['reward'],

'points' => $query->row['points'],

'tax_class_id' => $query->row['tax_class_id'],

'date_available' => $query->row['date_available'],

'weight' => $query->row['weight'],

'weight_class_id' => $query->row['weight_class_id'],

'length' => $query->row['length'],

'width' => $query->row['width'],

'height' => $query->row['height'],

'length_class_id' => $query->row['length_class_id'],

'subtract' => $query->row['subtract'],

'rating' => round($query->row['rating']),

'reviews' => $query->row['reviews'] ? $query->row['reviews'] : 0,

'minimum' => $query->row['minimum'],

'sort_order' => $query->row['sort_order'],

'status' => $query->row['status'],

'date_added' => $query->row['date_added'],

'date_modified' => $query->row['date_modified'],

'viewed' => $query->row['viewed'],

'shipping' => $query->row['shipping']

);

catalog/controller/product/product.php

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

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

if ($product_info) {

$url = '';

if (isset($this->request->get['path'])) {

$url .= '&path=' . $this->request->get['path'];

}

if (isset($this->request->get['filter'])) {

$url .= '&filter=' . $this->request->get['filter'];

}

if (isset($this->request->get['manufacturer_id'])) {

$url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];

}

if (isset($this->request->get['search'])) {

$url .= '&search=' . $this->request->get['search'];

}

if (isset($this->request->get['tag'])) {

$url .= '&tag=' . $this->request->get['tag'];

}

if (isset($this->request->get['description'])) {

$url .= '&description=' . $this->request->get['description'];

}

if (isset($this->request->get['category_id'])) {

$url .= '&category_id=' . $this->request->get['category_id'];

}

if (isset($this->request->get['sub_category'])) {

$url .= '&sub_category=' . $this->request->get['sub_category'];

}

if (isset($this->request->get['sort'])) {

$url .= '&sort=' . $this->request->get['sort'];

}

if (isset($this->request->get['order'])) {

$url .= '&order=' . $this->request->get['order'];

}

if (isset($this->request->get['page'])) {

$url .= '&page=' . $this->request->get['page'];

}

if (isset($this->request->get['limit'])) {

$url .= '&limit=' . $this->request->get['limit'];

}

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

'text' => $product_info['name'],

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

);

$this->document->setTitle($product_info['meta_title']);

$this->document->setDescription($product_info['meta_description']);

$this->document->setKeywords($product_info['meta_keyword']);

$this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');

$this->document->addScript('catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js');

$this->document->addStyle('catalog/view/javascript/jquery/magnific/magnific-popup.css');

$this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js');

$this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');

$this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');

$data['heading_title'] = $product_info['name'];

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

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

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

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

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

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

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

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

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

$data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);

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

$data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

$data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']);

$data['product_id'] = (int)$this->request->get['product_id'];

$data['manufacturer'] = $product_info['manufacturer'];

$data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);

$data['model'] = $product_info['model'];

$data['reward'] = $product_info['reward'];

$data['points'] = $product_info['points'];

$data['shipping'] = $product_info['shipping'];

catalog/view/theme/default/template/product/product.tpl

<?php if ($manufacturer) { ?>

            <li><?php echo $text_manufacturer; ?> <a href="<?php echo $manufacturers; ?>"><?php echo $manufacturer; ?></a></li>

            <?php } ?>

            <li><?php echo $text_model; ?> <?php echo $model; ?></li>

            <?php if ($reward) { ?>

            <li><?php echo $text_reward; ?> <?php echo $reward; ?></li>

            <?php } ?>

            <li><?php echo $text_stock; ?> <?php echo $stock; ?></li>

            <?php if ($shipping) { ?>

            <li><?php echo $text_shipping; ?> <?php echo $shipping; ?></li>

            <?php } ?>

 

И в Language добавил $_['text_shipping'] = 'Доставка:';

 

В итоге в карточке товара ничего не добавилось.

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


ну Вы хотите чтобы совсем разжевали :)

 

catalog/model/catalog/product.php

 

if ($query->num_rows) {
return array(

'shipping' => $query->row['shipping'],

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'product_id' => $query->row['product_id'],

 

 

catalog/controller/product/product.php

в любое место после if ($product_info) {

 

 

>>> И в Language добавил $_['text_shipping'] = 'Доставка:';

 

catalog/controller/product/product.php

в любое место после if ($product_info) {

$data['text_shipping'] = $this->language->get('text_shipping');
Надіслати
Поділитися на інших сайтах

 

ну Вы хотите чтобы совсем разжевали :)

 

catalog/model/catalog/product.php

 

if ($query->num_rows) {

return array(

'shipping' => $query->row['shipping'],

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

'product_id' => $query->row['product_id'],

 

 

catalog/controller/product/product.php

в любое место после if ($product_info) {

 

 

>>> И в Language добавил $_['text_shipping'] = 'Доставка:';

 

catalog/controller/product/product.php

в любое место после if ($product_info) {

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

Спасибо за помощь. Я реализовал задуманное следующим образом:

catalog/model/catalog/product.php

'shipping'          => $query->row['shipping'

В catalog/controller/product/product.php

$data['shipping'] = $product_info['shipping'];

и

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

в language

$_['text_shipping']            = 'Электронно';
$_['text_shipping_pochta']     = 'Физическая';

В catalog/view/theme/default/template/product/product.tpl

<?php if ($shipping <= 0) { ?>
            <li>Доставка: <?php echo $text_shipping; ?></li>
            <?php } else { ?>
            <li>ДоставкаА: <?php echo $text_shipping_pochta; ?></li>
            <?php } ?> 

Получилось вот так. Вроде работает правильно.

3734de2c97b0.png

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


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

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

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

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

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

Вхід

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

Вхід зараз
×
×
  • Створити...

Important Information

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