summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-05-22 14:40:50 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-05-22 14:40:50 +0800
commitec05878378bf14ad85aa07a9762ea00b99bc672f (patch)
treec5e54a05ad775d1579bc8b5604c5c7156754da3a
parenta091012bc03a43a3d62dc35769889d4a6fd8517d (diff)
Add check_opt when there's any option
-rw-r--r--ord.c16
1 files 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");