Post by Dexial » Sat Sep 19, 2020 4:24 pm

Hello,
can anyone tell me how to change this code so that quantity discounts are displayed in the table?

Code: Select all

{% if discounts %} 
					<ul class="list-unstyled text-success">
					{% for discount in discounts %} 
						<li><strong>{{ discount.quantity }} {{ text_discount }} {{ discount.price }}</strong> </li>
					{% endfor %}
					</ul>
				{% endif %} 	
Thanks in advance for your help
3.0.3.3
Last edited by Dexial on Sun Sep 20, 2020 4:33 am, edited 2 times in total.

Newbie

Posts

Joined
Sun Mar 08, 2020 12:53 am

Post by OSWorX » Sun Sep 20, 2020 1:28 am

What's wrong with that code?

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member
Online

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by straightlight » Sun Sep 20, 2020 1:46 am

The problem with this code is the discount quantity is only being called from the twig file but not instantiated from the controller where you are trying to make the call specifically. Since the debug twig engine is not enabled by default with OC, the error messages from TWIG files will not be shown.

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 thekrotek » Sun Sep 20, 2020 4:10 am

You can achieve this with CSS, don't even need to change the code.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by Dexial » Sun Sep 20, 2020 4:22 am

yes I know but i don't know CSS :)
problem solved

Code: Select all

{% if discounts %} 
<table style="height: auto; width: 100%;" border="1">
<tbody>
	<tr><td style="text-align: center; font-weight: bold;"">Quantity</td>
		{% for discount in discounts %} 			
		<td style="text-align: center; font-weight: bold;"">{{ discount.quantity }} </td>
		{% endfor %}			
	</tr>
	<tr><td style="text-align: center; font-weight: bold;"">Price</td>
{% for discount in discounts %} 			
		<td style="text-align: center; font-weight: bold;"">{{ discount.price }} </td>
		{% endfor %}			
	</tbody>
</table>

Newbie

Posts

Joined
Sun Mar 08, 2020 12:53 am

Post by OSWorX » Sun Sep 20, 2020 4:24 am

Dexial wrote:
Sun Sep 20, 2020 4:22 am
yes I know but i don't know CSS
problem solved
Great - fine for you.
But .. it would help others if you could write how you solved the problem.
And if, edit the first post and add [SOLVED] to the title.
thanks.

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member
Online

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by Dexial » Sun Sep 20, 2020 4:30 am

solution in the post above,
replacing the code in the first post on the one above results in displaying quantity discounts in the horizontal table,
thanks

Newbie

Posts

Joined
Sun Mar 08, 2020 12:53 am

Post by OSWorX » Sun Sep 20, 2020 5:05 am

Dexial wrote:
Sun Sep 20, 2020 4:30 am
solution in the post above,
replacing the code in the first post on the one above results in displaying quantity discounts in the horizontal table,
thanks
Well, beside the fact that such HTML code is not really "state-of-the-art" (did similiar many, many years ago ..), you have changed only from a list to a table.
So what is the benefit?

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member
Online

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by by mona » Sun Sep 20, 2020 6:21 am

As mentioned above, there are better ways to do this, but the old fashioned way is fine IF it was correct.

Code: Select all

{% if discounts %} 
<table style="height: auto; width: 100%; border:1px">
<tbody>
	<tr>
               <td style="text-align: center; font-weight: bold;">Quantity</td>
		{% for discount in discounts %} 			
		<td style="text-align: center; font-weight: bold;">{{ discount.quantity }} </td>
		{% endfor %}			
	</tr>
	<tr>
             <td style="text-align: center; font-weight: bold;">Price</td>
{% for discount in discounts %} 			
		<td style="text-align: center; font-weight: bold;">{{ discount.price }} </td>
		{% endfor %}			
	</tbody>
</table>
{% endif %}



This would be better

Code: Select all

{% if discounts %} 
<table class="discounttable">
<tbody>
	<tr>
               <td>Quantity</td>
		{% for discount in discounts %} 			
		<td>{{ discount.quantity }} </td>
		{% endfor %}			
	</tr>
	<tr>
             <td>Price</td>
{% for discount in discounts %} 			
		<td>{{ discount.price }} </td>
		{% endfor %}			
	</tbody>
</table>
{% endif %}


and to your stylesheet you add

Code: Select all

.discounttable {
height: auto; 
width: 100%; 
border:1px;
}
.discounttable td {
text-align: center; 
font-weight: bold;
}

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by OSWorX » Sun Sep 20, 2020 2:21 pm

by mona wrote:
Sun Sep 20, 2020 6:21 am
As mentioned above, there are better ways to do this, but the old fashioned way is fine IF it was correct.
....
by mona wrote:
Sun Sep 20, 2020 6:21 am
This would be better
Image

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member
Online

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by Dexial » Sun Sep 20, 2020 3:46 pm

OSWorX wrote:
Sun Sep 20, 2020 5:05 am
(...) you have changed only from a list to a table.
So what is the benefit?
OSWorX - I sell in bulk. Each product has more than 5 quantity discounts. The table looks much clearer. Additionally, I have modules that generate tables with options below. I wanted it to be consistent with the rest,

thanks by mona - that's what I needed.

Newbie

Posts

Joined
Sun Mar 08, 2020 12:53 am
Who is online

Users browsing this forum: Jane Blonde and 23 guests