From 3a0f07e6fafbdb8c3bf993c8dc59bb8673ad0818 Mon Sep 17 00:00:00 2001 From: Stacy Date: Tue, 23 Apr 2024 09:10:36 +0800 Subject: [PATCH] Product Single page CSS & Double click add to cart UI issue --- header.php | 28 +++++++--- product-left-sidebar.php | 109 ++++++++++++++++++++++----------------- 2 files changed, 85 insertions(+), 52 deletions(-) diff --git a/header.php b/header.php index 27c737d..2d002dc 100644 --- a/header.php +++ b/header.php @@ -140,6 +140,8 @@ if ($_SESSION["userId"] <> "") { line-height: 1; } + +
@@ -180,6 +182,7 @@ if ($_SESSION["userId"] <> "") {
+ +
@@ -308,6 +312,7 @@ if ($_SESSION["userId"] <> "") {
+
@@ -428,19 +433,30 @@ if ($_SESSION["userId"] <> "") {
- + + + Unit Price:
Subtotal:
-
-
-
- -
+
+
+
- +
+ +
+ +
- + + +
diff --git a/product-left-sidebar.php b/product-left-sidebar.php index 2849855..996e769 100644 --- a/product-left-sidebar.php +++ b/product-left-sidebar.php @@ -490,25 +490,31 @@ if (isset($_GET['id'])) { $product_price = (!empty($product_details['sale_price'])) ? $product_details['sale_price'] : $product_details['regular_price'] ; if ($_SESSION["isLoggedIn"]) { if ($product_details['product_type'] === "variable") { - echo '
-
'; + echo '
-
'; echo ''; - echo '
+
'; - echo '
'; + echo '" id="qty-input" />'; + echo '
+
'; + echo '
'; echo ''; echo '
'; } else { if (!empty($product_details['regular_price']) || !empty($product_details['sale_price'])) { - echo '
-
'; + echo '
-
'; echo ''; - echo '
+
'; - // echo '
'; - echo '
'; + echo '" id="qty-input" />'; + echo '
+
'; + echo '
'; echo '
'; @@ -518,7 +524,8 @@ if (isset($_GET['id'])) { } } else { echo ''; + echo '
'; } ?> -
-
-
- -
+
- -
- -
- `; + + product + +
+ ${response.items[0].product.name} + + Unit Price: ${response.items[0].price} + + Subtotal: ${totalAmount} + +
+
-
+ +
+
+ + +
+ +
+ `; getLatestOrders() updateCartItemCount() cartList.appendChild(newOrder); @@ -1166,23 +1177,29 @@ if (isset($_GET['id'])) { var totalAmount = response.items[0].price * updatedQuantity; // If the cart item already exists, update its content using innerHTML cartItem.innerHTML = ` - - product - -
- ${response.items[0].product.name} - - Unit Price: ${response.items[0].price} - - Subtotal: ${totalAmount} -
-
-
- -
+
-
- x -
- `; + + product + +
+ ${response.items[0].product.name} + + Unit Price: ${response.items[0].price} + + Subtotal: ${totalAmount} + +
+
-
+ +
+
+ + +
+ +
+ `; document.getElementById(`qty-input-${response.items[0]._id}`).value = updatedQuantity; } else { // If the cart item doesn't exist, create a new one