Last active
August 29, 2015 14:10
-
-
Save huoxito/0cd833e62f2f625ea235 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
var items = payload.shipment.items; | |
var new_items = []; | |
for (i = 0; i < items.length; i++) { | |
var item = items[i]; | |
var quantity = item.quantity; | |
if (item.bundled_items && item.bundled_items.length > 0) { | |
for (k = 0; k < item.bundled_items.length; k++) { | |
var bundle_item = item.bundled_items[k]; | |
var bundle_quantity = bundle_item.quantity; | |
for (x = 0; x < quantity; x++) { | |
for (z = 0; z < bundle_quantity; z++) { | |
bundle_item.quantity = 1; | |
new_items.push(bundle_item); | |
} | |
} | |
} | |
} else if (quantity > 1) { | |
for (x = 0; x < quantity; x++) { | |
item.quantity = 1; | |
new_items.push(item); | |
} | |
} else { | |
new_items.push(items[i]); | |
} | |
} | |
payload.shipment.items = new_items; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment