forked from Anushkabh/krishiconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transaction.js
25 lines (19 loc) · 1012 Bytes
/
transaction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var order = JSON.parse(localStorage.getItem('order'));
// Check if order is null or undefined
if (!order) {
var buyerDetailsContainer = document.getElementById('buyer-details');
buyerDetailsContainer.innerHTML = 'No Transactions Found';
var transactionItemsContainer = document.getElementById('transaction-items');
transactionItemsContainer.innerHTML = ''; // Clear any existing content
} else {
var buyerDetailsContainer = document.getElementById('buyer-details');
buyerDetailsContainer.innerHTML = 'Buyer Name: ' + order.buyerName + '<br>Email: ' + order.buyerEmail;
var transactionItemsContainer = document.getElementById('transaction-items');
order.items.forEach(function(item) {
var itemElement = document.createElement('div');
itemElement.innerHTML = item.name + ' - Rp ' + item.price + ' - Quantity: ' + item.quantity;
transactionItemsContainer.appendChild(itemElement);
});
// Remove the order from localStorage after displaying
localStorage.removeItem('order');
}