TomJones999
TomJones999

Reputation: 853

OpenCart 3.x - syntax issue with IF/ELSE loop

I have some code in OpenCart 2.0 template file, that includes this block:

<?php if($stock >= 1) { ?>
    (block of HTML #1)
<? } else { ?>
    (block of HTML #2)
<? } ?>

Attempting to implement the same in OpenCart 3.0 template, that uses the Twig language, results in "= 1) { ?>" showing up on the front end, followed by both HTML blocks.

I've looked at the OpenCart Twig documentation, but it's not clear what I'm doing wrong.

If anyone can provide an example of the proper code, I would really appreciate it.

Upvotes: 0

Views: 2291

Answers (1)

DigitCart
DigitCart

Reputation: 3000

In this example you can see how to echo a variable and how to compare it in twig:

stock is: {{ stock }}
<br>

{% if stock >= 1 %}
    (block of HTML #1)
{% else %}
    (block of HTML #2)
{% endif %}

Upvotes: 1

Related Questions