Skip to content

Instantly share code, notes, and snippets.

@tessguefen
Last active December 7, 2016 16:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tessguefen/1a8457c1a4774c614d53e32c9fb9d5f6 to your computer and use it in GitHub Desktop.
Save tessguefen/1a8457c1a4774c614d53e32c9fb9d5f6 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