Post by psytanium » Fri Apr 30, 2021 6:57 pm

Hello,

{% if product.quantity > 0 %} is working fine, but {% if product.quantity < 0 %} is considering the sign < as opening tag (like <div>) and result a html mess.

How do i write if quantity is less in twig ?

Thanks

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by straightlight » Fri Apr 30, 2021 8:28 pm

psytanium wrote:
Fri Apr 30, 2021 6:57 pm
Hello,

{% if product.quantity > 0 %} is working fine, but {% if product.quantity < 0 %} is considering the sign < as opening tag (like <div>) and result a html mess.

How do i write if quantity is less in twig ?

Thanks
OC version.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by psytanium » Fri Apr 30, 2021 8:31 pm

straightlight wrote:
Fri Apr 30, 2021 8:28 pm
psytanium wrote:
Fri Apr 30, 2021 6:57 pm
Hello,

{% if product.quantity > 0 %} is working fine, but {% if product.quantity < 0 %} is considering the sign < as opening tag (like <div>) and result a html mess.

How do i write if quantity is less in twig ?

Thanks
OC version.
3.0.2.0

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by JNeuhoff » Fri Apr 30, 2021 9:27 pm

The '<' operator is perfectly valid, see https://twig.symfony.com/doc/3.x/templa ... omparisons

Something else must have gone wrong with your OpenCart site.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by straightlight » Fri Apr 30, 2021 10:50 pm

Full code of the incident request needed to assist.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by psytanium » Sat May 01, 2021 1:28 am

straightlight wrote:
Fri Apr 30, 2021 10:50 pm
Full code of the incident request needed to assist.
This part is extracted from category.twig

Code: Select all

<div class="image rotate-image-container">
	{% if product.quantity < 0 %}
		<div class="insight-stock-label">{{ text_out_of_stock }}</div>
	{% endif %}
	<a href="{{ product.href }}">
		<img src="{{ product.thumb }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-responsive img-default-image" />
		{% if product.rotate_image %}
			<img src="{{ product.rotate_image }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-responsive img-rotate-image" />
		{% endif %}
	</a>
</div>

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by psytanium » Sat May 01, 2021 1:30 am

As a temporary compromise, I did the following ;D don't laugh

Code: Select all

{% if product.quantity > 0 %}
																
{% else %}
	<div class="insight-stock-label">{{ text_out_of_stock }}</div>
{% endif %}

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am
Who is online

Users browsing this forum: No registered users and 91 guests