OpenCart - 中文论坛

标题: opencart如何只能让登录会员看到商品价格 [打印本页]

作者: sunboy    时间: 2011-3-20 10:49
标题: opencart如何只能让登录会员看到商品价格
Top



如图:游客



For Visitors visitor.jpg (51.81 KiB) Viewed 57 times

会员登录显示
If the client has logged in, show as normal
For registered Logged in.jpg (51.1 KiB) Viewed 57 times

I've made some revise, it will be much better for multi-language system. Since I'm not so good in PHP, if anything wrong with the code, please let me know, but this works at our site. Thanks for all the helps and advise.

in catalog\controller\product\product.php add below
Code: Select all     $this->data['logged'] = $this->customer->isLogged();
       $this->data['text_login'] = $this->language->get('text_login');
      $this->data['login'] = HTTPS_SERVER . 'index.php?route=account/login';
    $this->data['text_create'] = $this->language->get('text_create');
    $this->data['create'] = HTTPS_SERVER . 'index.php?route=account/create';


in catalog\language\english\product\product.php add below
Code: Select all     $_['text_create']   = 'Register';
$_['text_login']    = 'Log In';


in catalog\view\theme\default\template\product\product.tpl revise it as below
Code: Select all               <tr>
                <td><b><?php echo $text_price; ?></b></td>
                <td>
    <?php if (!$logged) { ?>
      [ <a href="<?php echo $login; ?>"><?php echo $text_login; ?></a> ] [ <a href="<?php echo $create; ?>"><?php echo $text_create; ?></a> ]
    <?php } else { ?>
                  <?php if (!$special) { ?>
                  <span style="color: #900;"><?php echo $price; ?></span>
                  <?php } else { ?>
                  <span style="color: #900; text-decoration: line-through;"><?php echo $price; ?></span> <span style="color: #F00;"><?php echo $special; ?></span>
    <?php } ?>
                </td>
              <?php } ?>
              </tr>

.

find

Code: Select all <div class="content">
                <?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
                <a id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>
                <?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
              </div>

replace with

Code: Select all <div class="content">
<?php if ($logged) { ?>
                <?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
                <a id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>
                <?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?












欢迎光临 OpenCart - 中文论坛 (https://bbs.opencart.cn/) Powered by Discuz! X3.2