VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: gpessoa on January 12, 2022, 01:32:13 AM

Title: Condition to echo on category
Post by: gpessoa on January 12, 2022, 01:32:13 AM
Hi ppl,

I have a problem on a condition to echo my text on Category

If I use "my text" condition, it crashes...
<?php  
if  (
$product->product_availability == my text ) {
echo JText::_('MYTEXT').$sep ;
}
?>


However, the "my text" works fine on product detail view.

But, instead of using "my text" if I use "100", it works fine!
<?php  
if  (
$product->product_availability == 100 ) {
echo JText::_('MYTEXT').$sep ;
}
?>


I already try a few ways, but so far, got no luck!

Thanks in advanced
Title: Re: Condition to echo on category
Post by: Jörgen on January 12, 2022, 08:09:54 AM
<?php  
if  (
$product->product_availability == my text ) {
echo JText::_('MYTEXT').$sep ;
}
?>


What is :
my text

Syntax error, This will brake any language.

Are you looking to check for for $my_text ? or "my text" ? or ???

Jörgen
Title: Re: Condition to echo on category
Post by: gpessoa on January 12, 2022, 11:20:33 AM
Used the word "my text", but the word I want to use is "on stock"
I already try it with just "stock"
   It doesn't crashes, but also doesn't work properly
only echo MYTEXT tag language, and not the description under that tag
Title: Re: Condition to echo on category
Post by: GJC Web Design on January 12, 2022, 11:54:05 AM
<?php  
        $mytext 
JText::_('MYTEXT');
if  ($product->product_availability == $mytext ) {
echo JText::_('MYTEXT').$sep ;
}
?>
Title: Re: Condition to echo on category
Post by: gpessoa on January 12, 2022, 20:16:16 PM
Thank you GJC Web Design
Now it rocks!  8)