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

New 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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


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

New member

Posts

Joined
Fri Nov 27, 2015 2:07 am

User avatar
Expert 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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


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>

New 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 %}

New member

Posts

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

Users browsing this forum: No registered users and 18 guests