From ec05878378bf14ad85aa07a9762ea00b99bc672f 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: Mon, 22 May 2023 14:40:50 +0800 Subject: Add check_opt when there's any option --- ord.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ord.c b/ord.c index 62112c6..9e15a5b 100644 --- a/ord.c +++ b/ord.c @@ -25,6 +25,8 @@ void interchange_ord_order(const char *sku, const char *item, } for (size_t i = 0; i < nopts; i++) --options; + if (nopts) + nopts++; size_t total_nopts = 4 + nopts; const char *order[total_nopts + 1][2]; order[0][0] = "mv_action"; @@ -36,12 +38,16 @@ void interchange_ord_order(const char *sku, const char *item, order[3][0] = "mv_order_quantity"; order[3][1] = qty_str; static const char *prefix = "mv_order_"; - for (size_t i = 0; i < nopts; i++) { + if (nopts) { + order[4][0] = "mv_form_profile"; + order[4][1] = "check_opt"; + } + for (size_t i = 0; i < nopts - 1; i++) { const char **pair = options[i]; - order[4 + i][0] = malloc(strlen(prefix) + strlen(pair[0]) + 1); - sprintf((char *)order[4 + i][0], "%s%s", prefix, pair[0]); - order[4 + i][1] = malloc(strlen(pair[1]) + 1); - strcpy((char *)order[4 + i][1], pair[1]); + order[5 + i][0] = malloc(strlen(prefix) + strlen(pair[0]) + 1); + sprintf((char *)order[5 + i][0], "%s%s", prefix, pair[0]); + order[5 + i][1] = malloc(strlen(pair[1]) + 1); + strcpy((char *)order[5 + i][1], pair[1]); } order[total_nopts][0] = NULL; request(parser, NULL, order, "%s", "ord/basket"); -- cgit v1.2.3