Post by marius-ciclistu » Sat Aug 05, 2017 10:24 pm

Hello.
Can anyone please tell me in which file is the following code ( i'm guessing the code is similar to this)

Code: Select all

$price=$value . $currency; 
being asigned?
I want to not show price if $value==0 but instead show "Contact us" with link to the contact page.

I use OC 2.3.0.2.

Thank you.

New member

Posts

Joined
Sat Nov 24, 2012 6:22 am

Post by GoGo OpenCart » Sat Aug 05, 2017 11:47 pm

I have a module that can do what you want:

https://www.opencart.com/index.php?rout ... on_id=4139

If you want to check out a demo, or if you have any questions, feel free to write me a PM ;)

See all my extensions: https://www.opencart.com/index.php?rout ... 20OpenCart


User avatar
Active Member

Posts

Joined
Mon Nov 14, 2011 11:30 pm

Post by DigitCart » Sat Aug 05, 2017 11:54 pm

Hi,
If you want to do this on the product page, do one of the following:
Edit the view file

Code: Select all

catalog/view/theme/YOUR_THEME/template/product/product.tpl
Find

Code: Select all

<?php echo $price; ?>
Change it to:

Code: Select all

<?php
preg_match('/\$([0-9]+[\.]*[0-9]*)/', $price, $match);
$node_price = $match[1];
if($node_price != 0){
	echo $price;
} else {
	echo '<a href="index.php?route=information/contact">Contact us</a>';
}
?>

OR


Edit the controller file

Code: Select all

catalog/controller/product/product.php
Find

Code: Select all

if ((float)$product_info['special']) {
before it add

Code: Select all

if($product_info['price'] == 0){
	$data['price'] = '<a href="index.php?route=information/contact">Contact us</a>';
}
And then clear your vqmod and ocmod cache.

My Extensions / DigitCart


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by marius-ciclistu » Sun Aug 06, 2017 12:42 am

Hi.
Thank you very much.

I used this code to get what I want: and for replacing "Add to chart" text and link I'll edit all the files where it apears.

catalog/controller/product/product.php

Code: Select all

if($product_info['price'] == 0){
	$data['price'] = '';
}
if ((float)$product_info['special']) {
And for replacing "Add to chart" text and link I'll edit all the files where it appears, for example in
/catalog/view/theme/mytheme/template/product/product.tpl

Code: Select all

           <input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
              <br />
             <?php if($price!="") { ?>
              <button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>
              <?php } else { ?>    
              <button type="button" onclick="window.open('index.php?route=information/contact');" class="btn btn-primary btn-lg btn-block"><?php echo "Contact"; ?></button>
            <?php } ?>
            </div>
            <?php if ($minimum > 1) { ?>
Instead of

Code: Select all

              <input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
              <br />
             <button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>
            </div>
            <?php if ($minimum > 1) { ?>
DigitCart wrote:
Sat Aug 05, 2017 11:54 pm

OR


Edit the controller file

Code: Select all

catalog/controller/product/product.php
Find

Code: Select all

if ((float)$product_info['special']) {
before it add

Code: Select all

if($product_info['price'] == 0){
	$data['price'] = '<a href="index.php?route=information/contact">Contact us</a>';
}
And then clear your vqmod and ocmod cache.

New member

Posts

Joined
Sat Nov 24, 2012 6:22 am
Who is online

Users browsing this forum: No registered users and 11 guests