erpnext
erpnext copied to clipboard
Shipping Rule: add calculation option for quantity
The three available options for shipping rule are:
- Fixed
- Net Total
- Net Weight
There are however situations where calculating shipping based on Quantity are desirable. For example:
- You can only ship an item individually, therefore the shipping charge needs to a fixed amount x quantity
- You might want to specify a shipping charge limit, so let's say your shipping is fixed at £2 per item and the limit is £10, so with each additional quantity: £2, £4, £6, £8, £10, £10, £10, £10
- You might want to specify a percentage discount on shipping for each additional item, so let's say 20%, so with each additional quantity: 0%, 20%, 40%, 60%, 80%, 100%, 100%, 100%, 100%. i.e. if you order quantity 6, your shipping is free.
Combining the above the calculation would be:
min(shipping x quantity x (1 - min(percentage x (quantity - 1), 1)), shipping_limit)