From 33c252c6b2f509b6420c24d610dd99a15cda5593 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: Sun, 14 May 2023 16:12:41 +0800 Subject: Order can differentiate variant SKU from product --- ord.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'ord.c') diff --git a/ord.c b/ord.c index 8ffe17c..06d1798 100644 --- a/ord.c +++ b/ord.c @@ -6,10 +6,23 @@ #include "interchange/member.h" #include "interchange/ord.h" -void interchange_ord_order(const char *sku, - void (*handler)(interchange_response *)) +void interchange_ord_order(const char *sku, const char *item, + const unsigned int quantity, + void (*parser)(interchange_response *)) { - request(handler, NULL, NULL, "%s%s", "order?mv_arg=", sku); + 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, { + { "mv_action", "refresh" }, + { "mv_sku", sku }, + { "mv_order_item", item }, + { "mv_order_quantity", qty_str } + }}, "%s", "ord/basket"); } void interchange_ord_update(const char *name, const unsigned int quantity, -- cgit v1.2.3