Как добавить поле примечаний к заказу на странице корзины Woocommerce?

Я хотел бы добавить поле заметок на странице корзины Woocommerce в области купонов корзины Woocommerce. Это поле должно быть чем-то похожим на поле «Заметки заказа» на странице оформления заказа Woocommerce, где клиент может добавить некоторые заметки.

Пока у меня есть этот код, который указывает мое желаемое местоположение:

add_action ('woocommerce_after_cart_table','add_content_below_cart_coupon');
function add_content_below_cart_coupon () {
echo 'this will show below the cart cuopon';
}

область ниже woocommerce_cart_coupon

Как добавить поле заметок в эту область, чтобы эти заметки клиентов также отображались в деталях заказа на странице оформления заказа?

Спасибо!

2

Решение

Я решил эту проблему, но немного хакерский, я предлагаю поставить его в плагин

/**
* Add the order_comments field to the cart
**/
add_action('woocommerce_cart_collaterals', 'order_comments_custom_cart_field');

function order_comments_custom_cart_field() {
echo '<div id="cart_order_notes">';

?>
<div class="customer_notes_on_cart">
<label for="customer_notes_text"><?php _e('Order notes','woocommerce'); ?></label>
<textarea id="customer_notes_text"></textarea>
</div>
<?php



}

/**
* Process the checkout and overwriting the normal button
*
*/
function woocommerce_button_proceed_to_checkout() {
$checkout_url = wc_get_checkout_url();
?>
<form id="checkout_form" method="POST" action="<?php echo $checkout_url; ?>">
<input type="hidden" name="customer_notes" id="customer_notes" value="">
<a  href="#" onclick="document.getElementById('customer_notes').value=document.getElementById('customer_notes_text').value;document.getElementById('checkout_form').submit()" class="checkout-button button alt wc-forward">
<?php _e( 'Proceed to checkout', 'woocommerce' ); ?></a>
</form>
<?php
}


// getting the values in checkout again
add_action('woocommerce_checkout_before_customer_details',function(){
?>
<script>
jQuery( document ).ready(function() {
jQuery('#order_comments' ).val("<?php echo sanitize_text_field($_POST['customer_notes']); ?>");
});
</script>

<?php

});
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector