Post by Singh » Tue Aug 10, 2010 9:56 pm

Hello Everyone,

Sorry if this has been asked before. I have tried to search the forum but could not find the answer. I have just created a wholesale website and disabled the view prices, add to cart options. The users have to log-in in order to view prices and make a purchase.

I want to display a message under each category or if possible under each product which says "Please log-in to view prices" and when a user has logged in then this message should automatically disappear.

Can anyone please tell me, which files do I need to edit in order for this to work as I am not that good with PHP.

Thank You for your time and would really appreciate the help.

Newbie

Posts

Joined
Thu Jul 15, 2010 11:53 pm

Post by JAY6390 » Tue Aug 10, 2010 11:15 pm

Just put

Code: Select all

<?php if(!$this->user->isLogged()) : ?>
<span class="login-to-view">Please log-in to view prices</span>
<?php endif; ?>
In your templates where you want it to appear. I added a login-to-view class to make the styling easier for you

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Singh » Wed Aug 11, 2010 1:40 am

Hi, Jay6390

Thanks for replying.

I want the message to appear under each category. Which templates do I need to edit in order to put the above code in.

Newbie

Posts

Joined
Thu Jul 15, 2010 11:53 pm

Post by marcolang » Tue May 03, 2011 7:04 pm

I am getting error as below:

Fatal error: Call to a member function isLogged() on a non-object in C:\wamp\www\loja2\catalog\view\theme\default\template\product\product.tpl on line 53

Could someone help me?

Newbie

Posts

Joined
Tue May 03, 2011 6:56 pm

Post by fred123 » Fri Dec 02, 2011 11:30 pm

I also get the fatal error.

I would like this message on products and in the categories.

I cant find any other thread than this one so hopefully someone can point out where I am going wrong?

Thanks,

Active Member

Posts

Joined
Fri Aug 26, 2011 3:13 pm

Post by OpenCart Addons » Sat Dec 03, 2011 2:14 am

For the category page edit:
catalog / view / theme / <theme name> / template / product / category.tpl

For the product page edit:
catalog / view / theme / <theme name> / template / product / product.tpl


As for the fatal error, it doesn't seem to be able to locate the function in the system library.

Would it not be possible to do the following in the product page:

Code: Select all

<?php if ($price) { ?>
<span class="login-to-view">Please log-in to view prices</span>
<?php } ?>
And the following in the category page:

Code: Select all

<?php if ($product['price']) { ?>
<span class="login-to-view">Please log-in to view prices</span>
<?php } ?>

Joel

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by fred123 » Sat Dec 03, 2011 4:34 am

tried that but it does nothing, is there a specific place I need to put it?

Active Member

Posts

Joined
Fri Aug 26, 2011 3:13 pm

Post by OpenCart Addons » Mon Dec 05, 2011 12:53 pm

In catalog / controller / product / category.php

Find:

Code: Select all

$results = $this->model_catalog_product->getProducts($data);
After Add:

Code: Select all

if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$this->data['price'] = true;
} else {
$this->data['price'] = false;
}
In catalog / view / theme / <your theme> / template / product / category.tpl

Add:

Code: Select all

<?php if (!$price) { ?>
<span class="login-to-view">Please log-in to view prices</span>
<?php } ?>
In catalog / view / theme / <your theme> / template / product / product.tpl

Add:

Code: Select all

<?php if (!$price) { ?>
<span class="login-to-view">Please log-in to view prices</span>
<?php } ?>

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by fred123 » Mon Dec 05, 2011 9:31 pm

This is te site: www.wildflowerstudio-wholesale.com

where in the category and product tpl do I insert the script so it 'log in to view prices' displays in the pop up as you hover over the image?

Active Member

Posts

Joined
Fri Aug 26, 2011 3:13 pm

Post by OpenCart Addons » Mon Dec 05, 2011 10:11 pm

In catalog / view / theme / <your theme> / template / product / category.tpl

Find:

Code: Select all

 <?php if ($product['price']) { ?>
      <div class="price">
        <?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
        <?php } ?>
        <?php if ($product['tax']) { ?>
        <br />
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
        <?php } ?>
      </div>
      <?php } ?>
Add After:

Code: Select all

<?php else { ?>
<div class="price">
<span class="login-to-view">Please log-in to view prices</span>
</div>
<?php } ?>
In catalog / view / theme / <your theme> / template / product / product.tpl

Find:

Code: Select all

<?php if ($price) { ?>
      <div class="price"><?php echo $text_price; ?>
        <?php if (!$special) { ?>
        <?php echo $price; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $price; ?></span> <span class="price-new"><?php echo $special; ?></span>
        <?php } ?>
        <br />
        <?php if ($tax) { ?>
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $tax; ?></span><br />
        <?php } ?>
        <?php if ($points) { ?>
        <span class="reward"><small><?php echo $text_points; ?> <?php echo $points; ?></small></span> <br />
        <?php } ?>
        <?php if ($discounts) { ?>
        <br />
        <div class="discount">
          <?php foreach ($discounts as $discount) { ?>
          <?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?><br />
          <?php } ?>
        </div>
        <?php } ?>
      </div>
      <?php } ?>
Add After:

Code: Select all

<?php else { ?>
<div class="price">
<span class="login-to-view">Please log-in to view prices</span>
</div>
<?php } ?>
You will also have to make modifications to any product modules you use on your site. The changes should be similar to the category.tpl changes above.


Joel

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by fred123 » Tue Dec 06, 2011 1:41 am

That throws up:

Parse error: syntax error, unexpected T_ELSE in

on both product and category...

Active Member

Posts

Joined
Fri Aug 26, 2011 3:13 pm

Post by OpenCart Addons » Tue Dec 06, 2011 1:45 am

Find:

Code: Select all

<?php if ($price) { ?>
      <div class="price"><?php echo $text_price; ?>
        <?php if (!$special) { ?>
        <?php echo $price; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $price; ?></span> <span class="price-new"><?php echo $special; ?></span>
        <?php } ?>
        <br />
        <?php if ($tax) { ?>
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $tax; ?></span><br />
        <?php } ?>
        <?php if ($points) { ?>
        <span class="reward"><small><?php echo $text_points; ?> <?php echo $points; ?></small></span> <br />
        <?php } ?>
        <?php if ($discounts) { ?>
        <br />
        <div class="discount">
          <?php foreach ($discounts as $discount) { ?>
          <?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?><br />
          <?php } ?>
        </div>
        <?php } ?>
      </div>
      <?php } ?>
Change At End Of The Above:

Code: Select all

<?php } ?>
To:

Code: Select all

<?php } else { ?>
And Add After:

Code: Select all

<div class="price">
<span class="login-to-view">Please log-in to view prices</span>
</div>
<?php } ?>

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by fred123 » Tue Dec 06, 2011 3:41 am

it works, thanks :)

Active Member

Posts

Joined
Fri Aug 26, 2011 3:13 pm

Post by OpenCart Addons » Tue Dec 06, 2011 10:19 am

No problem.

Joel.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by bvisala » Sat Aug 22, 2015 4:34 pm

Is it possible to have the same thing in version 2.0.3.1.

Newbie

Posts

Joined
Sat Jul 11, 2015 5:26 am


Post by cosmicx » Fri Nov 18, 2016 2:39 am

I've tried doing this on OC 2.3.02 - but it does not work. No errors or anything on frontend. Could anyone please jump in and help?

Active Member

Posts

Joined
Mon Jan 09, 2012 6:27 pm


Post by IP_CAM » Fri Nov 18, 2016 9:38 am

Multiple Extensions for this already exist for latest Versions:
https://www.opencart.com/index.php?rout ... ew%20price

Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland


Post by cosmicx » Fri Nov 18, 2016 10:31 pm

Thanks for responding.

Though, I was looking for a do-it-yourself solution, by asking help here, then implement it myself.

Thanks!

Active Member

Posts

Joined
Mon Jan 09, 2012 6:27 pm
Who is online

Users browsing this forum: Majestic-12 [Bot] and 30 guests