【问题标题】:Opencart multiple product template based on stock statusOpencart 基于库存状态的多个产品模板
【发布时间】:2014-08-18 06:44:47
【问题描述】:

我想为我的 Opencart 商店中的某些产品再创建 1 或 2 个产品模板。我的供应商对哪些产品可以和不能在线销售有一定的限制。

  • 部分产品允许在线销售,可以显示价格
  • 有些产品可以在线定价,但没有添加到购物车按钮和显示“仅在店内有售”
  • 某些产品无法定价或添加到购物车

是否可以制作 2 个根据分配的库存状态更改的产品模板?就像链接帖子中的 OP 一样,我也想要可以在选项菜单中更改的内容。

OpenCart - View alternate product template based on arbitrary product field

【问题讨论】:

  • 您的问题的答案是:是的,有可能。当然,通过一些编码,因为 OpenCart 不允许更改产品模板的默认库存状态。

标签: php templates e-commerce opencart template-specialization


【解决方案1】:

您可以为您不想在没有价格或添加到购物车按钮的情况下出售的产品制作特定模板。

有一种方法,您可以为每个产品制作特定的模板。 您需要编辑 /catalog/controller/product/product.php 并找到该行:

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/product/product.tpl';
        } else {
            $this->template = 'default/template/product/product.tpl';
        }

并替换为:

 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
        '/template/product/product.tpl';

            $this->template = $this->config->get('config_template') . '/template/product/product_' . $this->request->get['product_id'] . '.tpl';
            if (!file_exists(DIR_TEMPLATE . $this->template)) {
            $this->template = $this->config->get('config_template') . '/template/product/product.tpl';
}
            } else {
                $this->template = 'default/template/product/product.tpl';
            }

现在您可以轻松创建特定模板,而无需在需要独特页面时始终修改 OpenCart。在 /catalog/view/theme/yourtemplate/template/product/product.php 中,如果您想要一个产品的特定模板,只需制作另一个名为 product_id.tpl

的文件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 2017-10-09
    相关资源
    最近更新 更多