Aleksmorshen commited on
Commit
8fccd7f
·
verified ·
1 Parent(s): 7a1d2b2

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +14 -8
script.js CHANGED
@@ -219,14 +219,20 @@ document.addEventListener('DOMContentLoaded', function () {
219
  let totalAmount = 0;
220
 
221
  cart.forEach(item => {
222
- const row = receiptTable.insertRow();
223
- row.innerHTML = `
224
- <td>${item.name}</td>
225
- <td>${item.quantity}</td>
226
- <td>${item.salePrice}</td>
227
- <td>${item.quantity * item.salePrice}</td>
228
- `;
229
- totalAmount += item.quantity * item.salePrice;
 
 
 
 
 
 
230
  });
231
 
232
  // Отображаем общую сумму
 
219
  let totalAmount = 0;
220
 
221
  cart.forEach(item => {
222
+ const products = JSON.parse(localStorage.getItem('products')) || [];
223
+ const product = products.find(p => p.id === item.id);
224
+
225
+ if (product) {
226
+ const row = receiptTable.insertRow();
227
+ row.innerHTML = `
228
+ <td>${item.name}</td>
229
+ <td>${item.quantity}</td>
230
+ <td>${product.itemsPerPack}</td>
231
+ <td>${item.salePrice}</td>
232
+ <td>${item.quantity * item.salePrice}</td>
233
+ `;
234
+ totalAmount += item.quantity * item.salePrice;
235
+ }
236
  });
237
 
238
  // Отображаем общую сумму