简体   繁体   中英

Redirect to checkout via a button in WooCommerce

I'm currently looking for a way to redirect directly to the checkout with a button click in an order. First, I've followed this question here to programmatically create orders for my customers with my custom order status pending-payment :

Programmatically creating new order in Woocommerce

After that I'm creating a programmatically product and adding it to the order.

Important to know is, that these orders are not paid yet.

Now I've a button <a class"button">Select and pay</a> in my order (Account -> Orders -> View Order Page).

When I click the button, I want to get redirected to the checkout to let the customer perform the normal checkout process with payment selection and all that stuff. So what kind of button do I need to perform this?

For clarification: You want to reinitiate the customer order that has already been placed in the system but with an extra product?

If you can grab the customer id you should be able to extra all the other data but logically I would think this will create a duplicate order (differant order IDs) but with the extra product.

What you would need to do is allow the user to edit orders via the button.

Have a look at Allow Users to Edit Processing Orders

You would need to change the order status to "On Hold" and then add the wc_order_is_editable filter to allow editing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM