Shopify Script -- Buy 1 Get 2nd, 3rd, 4th... 50% off (Shopify Scripts Experience is Must)

Job ID: 32148127

Budget: $30 – $250 CAD

Hello,

Hello I have made a script, but the way I wrote the script is in bad practice. I am looking for someone with Shopify Script/Ruby experience that can help me simplify my script and accomplish the use-case I am looking for. (Shopify Plus Store)

What I need is if a customer makes a purchase, (Certain Product Type, in my use case it is "Hair Extension") at full price, you then get all following products at 50% off (Same Product Type).

I do not have much Ruby Knowledge and need some help to create this script. I did create a version of the script, but I had made it very redundant (Made a campaign for each step) Code example is attached (Bogo 1 vs Bogo 2 vs Bogo 3).
Related categories: Ruby on Rails Shopify Shopify Development