summaryrefslogtreecommitdiff
path: root/pages/shop/cart/remove.fnl
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2025-08-31 17:51:57 +0600
committerunwox <me@unwox.com>2025-09-04 20:14:11 +0600
commit66c51b0e714fa8a1c80784108191270babc8525e (patch)
tree0640549f522092096d83c78b9be9b1fa4a03929e /pages/shop/cart/remove.fnl
parentd8039a77d582f696ab98b2a6d02ce924fbacfa41 (diff)
implement shop
Diffstat (limited to 'pages/shop/cart/remove.fnl')
-rw-r--r--pages/shop/cart/remove.fnl23
1 files changed, 23 insertions, 0 deletions
diff --git a/pages/shop/cart/remove.fnl b/pages/shop/cart/remove.fnl
new file mode 100644
index 0000000..d5e3531
--- /dev/null
+++ b/pages/shop/cart/remove.fnl
@@ -0,0 +1,23 @@
+(local lib (require :lib))
+
+(fn render [request db]
+ (if (= request.method "POST")
+ (let [order-id (lib.order-id request)]
+ (if (and order-id request.body)
+ (do
+ (local body-values (lib.parse-values request.body))
+ (_G.must
+ (luna.db.exec
+ db
+ "DELETE FROM order_lines WHERE id = ? AND order_id = ?"
+ [body-values.id order-id]))
+ (values
+ 302
+ {:Location (_G.must
+ (luna.http.decode-url
+ (or body-values.redirect-url "/shop")))}
+ ""))
+ (values 400 {} "bad body")))
+ (values 404 {} "not found")))
+
+{: render}