L
L
ligisayan2019-04-17 14:26:31
WooCommerce
ligisayan, 2019-04-17 14:26:31

How to add a page with validation of the entered data between the cart and payment in the woocommerce store?

Hello!
There is a woocommerce store .
I want to make a functional in which to combine the pages of the cart cart and checkout ckechout (product + address fields + choice of payment method), so that the buyer spends minimal effort to pay for the goods.
And then he got to the intermediate order confirmation page according to the principle as implemented in this WooCommerce Review Order plugin
. I work according to the visual guide
To implement this task, I transferred the client address fields from the checkout page to the cart like this

<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
<?php $fields = WC()->checkout()->get_checkout_fields( 'billing' );
foreach ( $fields as $key => $field ) {
    woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
}
$fields = WC()->checkout()->get_checkout_fields( 'shipping' );
foreach ( $fields as $key => $field ) {
    woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
} ?>
</form>

And the payment method is like this:
<div id="order_review" class="woocommerce-checkout-review-order">
    <?php do_action( 'woocommerce_checkout_order_review' ); ?>
</div>

Works, but redirects directly to thank you page . If you leave the payment method on the checkout page , it will show an error in filling in the buyer's address fields.
5cb70b61d2b38195890369.png
The payment method from checkout_order_review can be excluded in this way:
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );

But, on what hook then to hang up? Here I have a global plug in which direction to move. Can you help?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question