Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Can you spot the mistake in this one line mod? 'Dont display price v3 mod'


M1L0

Recommended Posts

Posted

Hi Guys,

 

I tried to install what looks like a very simple line of code which would change any items at a certain price (default is currently anything listed with a value of 0.00) and hide the price, replacing it with contact us, or send an email option.

 

On first look, it looks like it should work, but when incorporated to currencies.php I keep getting syntax errors. I have tried giggling it around but so far I still get errors. Can anyone see where this is going wrong?

 

Original code:

function display_price($products_price, $products_tax, $quantity = 1) {
 return $this->format($this->calculate_price($products_price, $products_tax, $quantity));
}
}

 

Current code:


function display_price($products_price, $products_tax, $quantity = 1) {
if ($products_price > 0.01){ //for change price by 'contact'
return $this->format($this->calculate_price($products_price, $products_tax, $quantity));
}else{
return 'Contact us';
}
}

 

In this instance I keep getting:

Parse error: syntax error, unexpected ';', expecting T_FUNCTION

 

Can anyone see whats wrong? I keep moving and shuffling the code but nothing seems to work.

Also wanted to ask why

if ($products_price > 0.01){ //for change price by 'contact'

has a > and not a <. Wouldn't that mean it would change everything over 0.01?

Posted

Your 'Current code' needs to have a right-hand curly bracket after it

function display_price($products_price, $products_tax, $quantity = 1) {
if ($products_price > 0.01){ //for change price by 'contact'
return $this->format($this->calculate_price($products_price, $products_tax, $quantity));
}else{
return 'Contact us';
}
}
}

as has your 'Original code'. The corresponding left-hand bracket is in line

class currencies {

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...