Repeat loop over products and then split line items

Shopify Expert
523 0 34

Hi All,

Trying to work out how to take ever item in the cart and split them into quantity = 3 and quantity = 2 line items

Has anyone accomplished this?

 

Trevor www.carlowseo.com
0 Likes
Highlighted
Shopify Partner
221 0 13

Hey Carlow,

Its not exactly clean and not sure if its what you are trying to acomplish, but I did a Script where you can set up the number of product to get 1 free. Like the BOGO Script from the examples. I think you could change the code to suit your needs. Hope it helps :P 

https://github.com/JFeuchter/Shopify-Scripts/blob/master/BXGXFREE.rb

If you have any question Ill be happy to help :D 

Entrepreneur, Developer, Geek, Gamer and very passionate about WEB development! :P

Need help with your Shopify Store? Contact me: jfeuchter@gmail.com :D
0 Likes
Shopify Expert
523 0 34

Hi Jurgen

This is great... except again it only loops 1 time over each line item. It doesn't loop over the line item... then the newly created line items and continue until there are no more possible groups of 3 or 2

As an example... 

  1. Original Line Item = 6 this is then 2 groups of 3 
  2. Original Line Item = 8 then this is 2 groups of 3 and one group of 2
  3. Original Line Item = 7 this one would be 2 groups of three 1 group of 1
  4. Original Line item = 5 is one group of 3 one group of 2

 

Trevor www.carlowseo.com
0 Likes