Post by foobarac » Fri Sep 21, 2018 9:52 pm

On my cart page, the “shipping” module is appearing between “Coupon Code” and “Gift Certificate” modules. This is in the incorrect order.

Is there any way to order the modules or change the code so that the “shipping” module is last in this block. Especially on mobile, it doesn’t look right as you want it to be the last module before the “total” module is displayed.

I found the code that’s rendering this page here:

~/catalog/view/theme/..../template/checkout/cart.twig

<div class="col-sm-7">
<div class="row cart-modules">
{% if modules %}
{% for module in modules %}
<div class="col-sm-6 margin-b30">
{{ module }}
</div>
{% endfor %}
{% endif %}
</div>
</div>


I was thinking to add some condition code to this code to bypass if it is the "shipping" module and then re-iterate again through the array again and to put it last.

However I am not sure how to test if the module is “shipping”, or if this is the best way to do it ?

Thanks in advanced.

New member

Posts

Joined
Fri Sep 21, 2018 9:46 pm

Post by Johnathan » Fri Sep 21, 2018 11:12 pm

The order of the line items is determined by your Order Total extension's sort orders. You can change them in Extensions > Order Totals if you want them in a different order. Just make sure that "Sub-Total" is always first, and "Total" is always last.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by foobarac » Mon Sep 24, 2018 10:31 pm

Hi Jonathan,

Thanks for the reply, I tried that already and it doesn't work. As a double check I re-arranged it to something obvious just to prove it but it still doesn't work (reloaded the modules and theme as well).

Is there any methods available to the twig code (from the php controller) on the "module" item from the "modules" array that I can test ? For example something like:

if module.name == "shipping" ....

New member

Posts

Joined
Fri Sep 21, 2018 9:46 pm

Post by Johnathan » Mon Sep 24, 2018 11:22 pm

Sorry, I thought you were talking about line items on the order, not the 3 module boxes that appear on the cart page. Try this edit and see if it works:

------------------------------------------------------------------------------
IN:
/catalog/controller/checkout/cart.php

BEFORE:
if ($files) {

ADD:
$files = array('coupon', 'voucher', 'shipping');
------------------------------------------------------------------------------

Don't forget to refresh your ocMod cache in Extensions > Modifications and your Twig cache (using the gear icon in the main admin dashboard). Otherwise you may not see any results from the edit.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by foobarac » Tue Sep 25, 2018 6:38 pm

A big thanks, worked a treat !

New member

Posts

Joined
Fri Sep 21, 2018 9:46 pm

Post by Johnathan » Wed Sep 26, 2018 11:08 pm

Glad I could help. :)

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am

Who is online

Users browsing this forum: No registered users and 270 guests