在Opencart 2的产品页面中显示重量单位

时间:2015-06-10 14:58:21

标签: php opencart opencart2.x

嗨!

如何在Opencart 2.0.2.0的产品页面中显示重量单位(kg。,gr。,oz。,ml。)

现在只显示没有单位的数字。

我正在使用默认模板

文件 template \ product \ product.tpl 中的

如下所示:

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

<?php if ($weight) { ?>

<li><?php echo $text_weight; ?>
<?php
echo round($weight, 2)?></li>
 <?php } ?> ...

in

目录\控制器\产品\ product.php

我添加了一行

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

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

还有什么需要添加或者可能会改变?

1 个答案:

答案 0 :(得分:4)

尝试使用默认的OpenCart代码。

第1步

打开文件$data['text_tags'] = $this->language->get('text_tags');

查找(第242行):

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

添加后:

catalog/controller/product/product.php


第2步

在同一档案$data['points'] = $product_info['points'];

查找(第270行左右):

$data['weight'] = $product_info['weight'];
$tablewunit = $this->db->query("SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE (wcd.weight_class_id = " . $product_info['weight_class_id'] . ") AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
$data['weightunit'] = $tablewunit->row['unit'];

添加后:

catalog/language/english/product/product.php


第3步

打开文件$_['text_model'] = 'Product Code:';

查找(第6行):

$_['text_weight']       = 'Weight:';

添加后:

catalog/view/theme/default(your theme)/template/product/product.tpl


第4步

打开文件<li><?php echo $text_model; ?> <?php echo $model; ?></li>

查找(第141行左右):

<li><?php echo $text_weight; ?> <?php echo $weight . ' ' . $weightunit; ?></li>

添加后:

SET  @FechaActual = datepart("hhmi",convert(datetime, 'JUN 11 2015 11:00AM', 100))

SET @HoraComienzoTurno1 = datepart("hhmi",convert(datetime,convert(varchar, @FechaActual, 101) + " 08:00:00 AM"))
SET @HoraFinTurno1 = datepart("hhmi",convert(datetime,convert(varchar, @FechaActual, 101) + " 03:29:59 PM"))
SET @HoraComienzoTurno2 = datepart("hhmi",convert(datetime,convert(varchar, @FechaActual, 101) + " 03:30:00 PM"))
SET @HoraFinTurno2 = datepart("hhmi",convert(datetime,convert(varchar, @FechaActual, 101) + " 10:59:59 PM"))
SET @HoraComienzoTurno3 = datepart("hhmi",convert(datetime,convert(varchar, @FechaActual, 101) + " 11:00:00 PM"))
SET @HoraFinTurno3 = datepart("hhmi",convert(datetime,convert(varchar, @FechaActual, 101) + " 07:59:59 AM"))

IF @FechaActual >= @HoraComienzoTurno1 AND @FechaActual <= @HoraFinTurno1
BEGIN
    SELECT 1 AS Turno, @FechaActual AS FechaActual
END

IF @FechaActual >= @HoraComienzoTurno2 AND @FechaActual <= @HoraFinTurno2 
BEGIN
    SELECT 2 AS Turno, @FechaActual AS FechaActual
END

IF @FechaActual >= @HoraComienzoTurno3 OR @FechaActual <= @HoraFinTurno3 
BEGIN
    SELECT 3 AS Turno, dateadd(dd, -1, @FechaActual) AS FechaActual
END

然后检查它。