We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
<script>
// JavaScript function to handle adding to cart
function addToCart(plantId, plantName, price) { // Create a new AJAX request var xhr = new XMLHttpRequest(); xhr.open("POST", "cartpop.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// Set up a callback to handle the response
xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { // Show the cart popup with details styled like the image document.getElementById('cartItemDetails').innerHTML = ` <div style="text-align: left;"> <img src="images/categories/${plantId}.jpg" alt="${plantName}" style="width: 50px; height: 50px;"> <div><strong>${plantName}</strong></div> <div>Size: Small</div> <div>Price: $${price}</div> </div> <div style="margin-top: 20px;"> <button onclick="window.location.href='viewCart.php'" class="button-primary">View my cart (1)</button> <button onclick="window.location.href='checkout.php'" class="button-secondary">Proceed to Checkout</button> </div> <button onclick="closeModal()" class="button-tertiary">Continue shopping</button> `; document.getElementById('cartPopup').style.display = "block"; } };
// Send the request with the plant ID
xhr.send("plant_id=" + plantId); }
// Function to close the modal
function closeModal() { document.getElementById('cartPopup').style.display = "none"; } </script>