You can copy from this excel format:
to source code using this web site:
https://ozh.github.io/ascii-tables/
Here is a demo
Great for pasting into your source code.
Note that this example also shows how to do min order qty, as well as 'must order packet size' / unit of stock / 'Standard Pack Size'
if (data.UnitOfStockSale > 0) { //+---------------+---------------+---------------------+--+-------------+ //| | min order qty | 10 | | | //+---------------+---------------+---------------------+--+-------------+ //| | unit of sale | 5 | | | //| | | | | | //| requested qty | | mod of unit of sale | | new req amt | //| 1 | | -1 | | 5 | //| 2 | | -2 | | 5 | //| 3 | | -3 | | 5 | //| 4 | | -4 | | 5 | //| 5 | | 0 | | 5 | //| 6 | | -1 | | 10 | //| 7 | | -2 | | 10 | //| 8 | | -3 | | 10 | //| 9 | | -4 | | 10 | //| 10 | | 0 | | 10 | //| 11 | | -1 | | 15 | //| 12 | | -2 | | 15 | //| 13 | | -3 | | 15 | //| 14 | | -4 | | 15 | //| 15 | | 0 | | 15 | //| 16 | | -1 | | 20 | //| 17 | | -2 | | 20 | //| 18 | | -3 | | 20 | //| 19 | | -4 | | 20 | //+---------------+---------------+---------------------+--+-------------+ int newQty = qty;//calc diff to add var modAmt = -( qty % data.UnitOfStockSale); //do mod operator var amtToAdd=0; if (modAmt != 0) { amtToAdd = data.UnitOfStockSale + modAmt; newQty = qty + amtToAdd; } basketLine.Quantity = newQty; data.Quantity = newQty; if (data.MinOrderQuantity > newQty) { basketLine.Quantity = data.MinOrderQuantity; data.Quantity = data.MinOrderQuantity; } data.InfoMessage += "\n Rounded up the quantity the nearest required order amount (you must order lots of " + data.UnitOfStockSale + ") by adding "+amtToAdd+"."; }
Ive downloaded a copy of the tool from github also.
Leave a Comment
Comments