0

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?

Mr. Jo
  • 4,946
  • 6
  • 41
  • 100

1 Answers1

1

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.

Shado
  • 120
  • 6
  • A bit. I want to create an order and set the customer so he can see the order in his account. In the order I need a button. With this button the customer can get to cart for payment. Before he paid his order, the status will be on hold, yes. So do you know how to get the payment link for an order? – Mr. Jo Jul 27 '19 at 22:46
  • I am not sure how automated you want the process. If the customer already has an account you can manually great the the order in WooCommerce -> Orders -> Add New. Then use the Order Actions to send the customer the necessary details. This would mean that you have to create the order in the backend but other than editing the mail template you don't need any other coding. – Shado Jul 27 '19 at 23:09
  • I've created a better explained follow-up question: https://stackoverflow.com/questions/57268840/woocommerce-get-pending-order-back-into-cart-and-checkout – Mr. Jo Jul 30 '19 at 10:14