Home › Forums › WoodMart support forum › send cart list without payment › Reply To: send cart list without payment
mahnaz
Thank you so much
can we use code for that and add this feature for emaple :
// Add custom button to the checkout page below the “Place Order” button
add_action(‘woocommerce_review_order_after_submit’, ‘custom_button_below_place_order’);
function custom_button_below_place_order() {
?>
<button type=”button” id=”send_to_admin” class=”button alt”>Send to Admin</button>
<script type=”text/javascript”>
jQuery(function($) {
$(‘#send_to_admin’).click(function(e) {
e.preventDefault();
$.ajax({
type: ‘POST’,
url: wc_checkout_params.ajax_url,
data: {
action: ‘send_product_info_to_admin’,
order_data: $(‘form.checkout’).serialize()
},
success: function(response) {
alert(response);
}
});
});
});
</script>
<?php
}
// Handle the AJAX request to send product information to the admin
add_action(‘wp_ajax_send_product_info_to_admin’, ‘send_product_info_to_admin’);
add_action(‘wp_ajax_nopriv_send_product_info_to_admin’, ‘send_product_info_to_admin’);
function send_product_info_to_admin() {
if (isset($_POST[‘order_data’])) {
parse_str($_POST[‘order_data’], $order_data);
// Get product information
$items = WC()->cart->get_cart();
$product_info = ”;
foreach($items as $item => $values) {
$product = wc_get_product($values[‘data’]->get_id());
$product_info .= ‘Product: ‘ . $product->get_name() . ‘<br>’;
$product_info .= ‘Quantity: ‘ . $values[‘quantity’] . ‘<br>’;
$product_info .= ‘Price: ‘ . $product->get_price() . ‘<br><br>’;
}
// Send email to admin
$to = get_option(‘admin_email’);
$subject = ‘Product Information from Checkout Page’;
$message = ‘Customer has sent the following product information:<br><br>’ . $product_info;
$headers = array(‘Content-Type: text/html; charset=UTF-8’);
wp_mail($to, $subject, $message, $headers);
echo ‘Product information sent to admin successfully.’;
} else {
echo ‘Failed to send product information.’;
}
wp_die();
}
and or customer has two option for that
thanks