From 8899052cef9b4e8d2682279ab9bc2d3ae09cb0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sat, 13 May 2023 18:06:01 +0800 Subject: Function for updating quantity --- ord.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'ord.c') diff --git a/ord.c b/ord.c index a3019e7..8ffe17c 100644 --- a/ord.c +++ b/ord.c @@ -1,3 +1,4 @@ +#include #include #include #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"); -- cgit v1.2.3