Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Forked from tessguefen/example.xml
Created December 7, 2016 16:14
Show Gist options
  • Save steveosoule/0afcaf8c8688cd9f7a925cf08d33b6b1 to your computer and use it in GitHub Desktop.
Save steveosoule/0afcaf8c8688cd9f7a925cf08d33b6b1 to your computer and use it in GitHub Desktop.
Group Products Codes together into new array
<mvt:foreach iterator="group" array="basket:groups">
<mvt:comment> <!-- Build Dynamic Array --> </mvt:comment>
<mvt:if expr="miva_array_search( l.settings:new_array, 0, l.item, 'l.item:code EQ l.settings:group:code' )">
<mvt:assign name="l.item:quantity" value="l.item:quantity + l.settings:group:quantity" />
<mvt:else>
<mvt:assign name="l.success" value="miva_array_insert( l.settings:new_array, l.settings:group, -1 )" />
</mvt:if>
<mvt:comment> <!-- Build Dynamic Array --> </mvt:comment>
</mvt:foreach>
<mvt:foreach iterator="item" array="new_array">
&mvt:item:code; // Total: &mvt:item:quantity;
</mvt:foreach>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment