Post by chrisgwynne » Wed Dec 06, 2017 10:40 pm

Hi guys

Just trying to show a message if there's one item left in stock, I've tried...

Code: Select all

<?php if($text_stock = '1') { ?>HELLO<?php ; } else { ?><?php } ?>
As well as

Code: Select all

<?php if($text_stock <= '2') { ?>HELLO<?php ; } else { ?><?php } ?>
And neither seem to work. I'm putting this in product.tpl. Any ideas on how to achieve this? Opencart 2.3.0.2

New member

Posts

Joined
Fri Nov 11, 2016 7:33 am

Post by straightlight » Wed Dec 06, 2017 10:47 pm

No OC version provided.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by chrisgwynne » Wed Dec 06, 2017 11:02 pm

Last sentence of the first post....... :laugh: Opencart 2.3.0.2

New member

Posts

Joined
Fri Nov 11, 2016 7:33 am

Post by MrPhil » Wed Dec 06, 2017 11:04 pm

Ugh! Please don't write code like that, constantly jumping in and out of PHP for no good reason. Next, "equality" is ==, not =. You're doing an assignment. Is $text_stock a number? If so, don't put quotes around the 1. Why do you have an empty "else" clause? It's useless.

Code: Select all

<?php if ($text_stock == 1) { print "HELLO"; } ?>

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by straightlight » Wed Dec 06, 2017 11:05 pm

Good catch. Although, I meant to say: from which controller file in this case.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 11 guests