Cart page item mail to form

You're looking to create a form on your cart page that allows customers to enter their email address and receive a copy of their cart contents via email. Here's a basic example of how you can achieve this:

HTML:

<form id="cart-email-form">
  <label for="email">Enter your email address:</label>
  <input type="email" id="email" name="email" required>
  <button type="submit">Send Cart to Email</button>
</form>

JavaScript:

document.getElementById('cart-email-form').addEventListener('submit', function(event) {
  event.preventDefault();
  var email = document.getElementById('email').value;
  var cartItems = [];
  // Get the cart items from your cart storage (e.g. local storage, session storage, etc.)
  // For this example, let's assume you have an array of cart items stored in a variable called 'cart'
  cart.forEach(function(item) {
    cartItems.push(item.name + ' - ' + item.price);
  });
  var cartContent = 'Cart Contents:\n' + cartItems.join('\n');
  var emailBody = 'Subject: Your Cart Contents\n\n' + cartContent;
  // Send the email using your preferred email service (e.g. Mailgun, Sendgrid, etc.)
  // For this example, let's assume you're using a simple email service that takes a subject and body as parameters
  sendEmail(email, emailBody);
});

PHP (if you're using a server-side language):

<?php
if (isset($_POST['email'])) {
  $email = $_POST['email'];
  $cartItems = [];
  // Get the cart items from your cart storage (e.g. session storage, etc.)
  // For this example, let's assume you have an array of cart items stored in a variable called 'cart'
  foreach ($cart as $item) {
    $cartItems[] = $item['name']. ' - '. $item['price'];
  }
  $cartContent = 'Cart Contents:'. "\n". implode("\n", $cartItems);
  $emailBody = 'Subject: Your Cart Contents'. "\n\n". $cartContent;
  // Send the email using your preferred email service (e.g. PHPMailer, etc.)
  // For this example, let's assume you're using a simple email service that takes a subject and body as parameters
  sendEmail($email, $emailBody);
}
?>

CSS (optional):

#cart-email-form {
  margin-top: 20px;
}

#cart-email-form input[type="email"] {
  width: 100%;
  height: 40px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

#cart-email-form button[type="submit"] {
  background-color: #4CAF50;
  color: #fff;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#cart-email-form button[type="submit"]:hover {
  background-color: #3e8e41;
}

This is a basic example, and you'll need to modify it to fit your specific use case. You'll also need to implement the sendEmail function to actually send the email to the customer.