Currently this function emails the person who inputs their email in the text field and the sender is our API ecommerce email. The To: is the person who made the request. My trouble is I can't seem to add possibly a CC: field to also add so we know who made the request. Below is the function, there's more to it that I can provide if needed.
$('#emailCart').click(function(e) {
e.preventDefault();
Swal.fire({
title: 'Enter Email',
input: 'text',
showCancelButton: true,
confirmButtonText: 'Email Cart',
preConfirm: (email) => {
if (email.length === 0 || !emailIsValid(email)) {
Swal.showValidationMessage('Please enter a valid email address.');
}
}
}).then((result) => {
if (result.value) {
$.ajax({
url: apiUrl + '/cart/email',
method: 'post',
headers: {
'X-CSRF-TOKEN': csrfToken
},
data: {
email: result.value
},
success: function() {
Swal.fire({
type: 'success',
title: 'Success',
text: 'Your cart has been emailed.',
timer: 1500
});
},
error: function() {
Swal.fire({
type: 'error',
title: 'Oops...',
text: 'Cart could not be emailed.'
})
}
});
}
});
});