summaryrefslogtreecommitdiff
path: root/ord.c
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-05-13 18:06:01 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-05-13 18:06:01 +0800
commit8899052cef9b4e8d2682279ab9bc2d3ae09cb0ce (patch)
tree05375fb9931fb03235cbe13044101ad177307afd /ord.c
parent77ded2a3b9142073f1ea74b948ad3219c6b245df (diff)
Function for updating quantity
Diffstat (limited to 'ord.c')
-rw-r--r--ord.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/ord.c b/ord.c
index a3019e7..8ffe17c 100644
--- a/ord.c
+++ b/ord.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "request.h"
@@ -11,13 +12,21 @@ void interchange_ord_order(const char *sku,
request(handler, NULL, NULL, "%s%s", "order?mv_arg=", sku);
}
-void interchange_ord_remove(const char *name, const char *orderpage,
- const char *nextpage, void (*parser)(interchange_response *))
+void interchange_ord_update(const char *name, const unsigned int quantity,
+ const char *orderpage, const char *nextpage,
+ void (*parser)(interchange_response *))
{
+ size_t length = 0;
+ unsigned int qty = quantity;
+ do {
+ length++;
+ } while ((qty /= 10));
+ char qty_str[length + 1];
+ sprintf(qty_str, "%d", quantity);
request(parser, NULL, &(struct body){ 4 + (nextpage ? 1 : 0), {
{ "mv_quantity_update", "1" },
{ "mv_doit", "refresh" },
- { name, "0" },
+ { name, qty_str },
{ "mv_orderpage", orderpage ? orderpage : "ord/basket" },
{ "mv_nextpage", nextpage }
}}, "%s", "process");