Adityadn commited on
Commit
c6448b0
·
verified ·
1 Parent(s): 4a97c42

Upload 7 files

Browse files
Files changed (2) hide show
  1. javascript/cart.js +4 -4
  2. javascript/payment.js +2 -3
javascript/cart.js CHANGED
@@ -86,7 +86,9 @@ async function loadCart() {
86
  do {
87
  const cart = await getCarts();
88
  const params = new URLSearchParams(window.location.search);
89
- const message = params.get("message") || "";
 
 
90
 
91
  let cartCount = {};
92
  cart.forEach((id) => {
@@ -145,9 +147,7 @@ async function updateQuantity(productId, newQty) {
145
  return;
146
  }
147
 
148
- // Ambil keranjang yang ada
149
  const cart = await getCarts();
150
- // Hapus semua kemunculan produk dengan productId tersebut
151
  const newCart = cart.filter((id) => id !== productId);
152
  // Tambahkan produk sesuai newQty
153
  for (let i = 0; i < newQty; i++) {
@@ -184,4 +184,4 @@ document.addEventListener("DOMContentLoaded", function () {
184
  if (document.getElementById("cart-items")) {
185
  loadCart();
186
  }
187
- });
 
86
  do {
87
  const cart = await getCarts();
88
  const params = new URLSearchParams(window.location.search);
89
+ const message = params.get("message") || "";
90
+
91
+ if (message) alert(message, false);
92
 
93
  let cartCount = {};
94
  cart.forEach((id) => {
 
147
  return;
148
  }
149
 
 
150
  const cart = await getCarts();
 
151
  const newCart = cart.filter((id) => id !== productId);
152
  // Tambahkan produk sesuai newQty
153
  for (let i = 0; i < newQty; i++) {
 
184
  if (document.getElementById("cart-items")) {
185
  loadCart();
186
  }
187
+ });
javascript/payment.js CHANGED
@@ -187,7 +187,7 @@ async function saveInfoAndLanjut() {
187
  email: userData.email,
188
  phone: phone,
189
  address: address,
190
- picture: userData.picture,
191
  cart: userData.cart,
192
  transactions: transactions,
193
  };
@@ -508,8 +508,7 @@ async function initPaymentSteps() {
508
  const cart = await getCarts();
509
 
510
  if (cart.length === 0)
511
- window.location.href =
512
- "cart.html?message=Anda belum memesan produk apapun. Pergi ke halaman produk untuk berbelanja";
513
 
514
  products = await fetchProductsData();
515
  switch (step) {
 
187
  email: userData.email,
188
  phone: phone,
189
  address: address,
190
+ photo_profile: userData.photo_profile,
191
  cart: userData.cart,
192
  transactions: transactions,
193
  };
 
508
  const cart = await getCarts();
509
 
510
  if (cart.length === 0)
511
+ window.location.href = `cart.html?message=${encodeURIComponent("Anda belum memesan produk apapun. Pergi ke halaman produk untuk berbelanja")}`;
 
512
 
513
  products = await fetchProductsData();
514
  switch (step) {