diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-17 22:42:03 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-17 22:42:03 +0800 |
commit | e9e2ea78fa012e909aff1b0f0838c321e496fb67 (patch) | |
tree | 12dc27f5d4a16f0e9277af8407a00398f8942c96 | |
parent | 12150c2dff8d226987beb78c8d37f595d90502eb (diff) |
nitems include item quantities that are more than 1
-rw-r--r-- | anteraja.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -112,15 +112,15 @@ void anteraja_order(const char *order_number, const char *service, const char *s + ORDER_ITEM_PRICE + ORDER_ITEM_WEIGHT - strlen("%s") - 3 * strlen("%d") + strlen(","); char item[length + 1]; - double weight = atof(items[i][WEIGHT]) * 1000.0; - if (weight < 100.0) - weight = 100.0; + int quantity = atoi(items[i][QUANTITY]); double price = atof(items[i][PRICE]); if (price < 1000.0) price = 1000.0; - sprintf(item, ORDER_ITEM, items[i][DESCRIPTION], atoi(items[i][QUANTITY]), (int)price, - (int)weight); + double weight = atof(items[i][WEIGHT]) * 1000.0; + if (weight < 100.0) + weight = 100.0; total_weight += weight; + sprintf(item, ORDER_ITEM, items[i][DESCRIPTION], quantity, (int)price, (int)weight); if (json) json = realloc(json, strlen(json) + length + 1); else { @@ -132,6 +132,7 @@ void anteraja_order(const char *order_number, const char *service, const char *s strcat(json, ","); else json[strlen(json)] = '\0'; + i += quantity - 1; } *post = malloc(strlen(ORDER_POST) + strlen(prefix) + strlen(order_number) + strlen(service) + ORDER_WEIGHT + strlen(sender_name) + strlen(sender_phone) + strlen(origin) |