How to allow your customers to modify their orders? Just like Amazon

Have you ever stopped to think how many times we complain about Amazon, about their power and presence in e-commerce, and have you thought about why you do nothing to imitate all the good things they do?

There are many examples of why Amazon sells more than you, and even seen some tricks that we can apply to compete with Amazon, but we are always missing something, some feature of the most successful online store in the world that we do not apply in our online store, either by ignorance or by simple laziness.

Well, no more sitting on the couch, and from today I want to see you offering in your online store that your customers can modify their orders before they are completed.

Why it is interesting to allow customers to modify their orders

There are many possible reasons why it is good for your customers to be able to modify their orders before they are completed, but the main ones I consider to be these:

Amazon offers it and you like it

Do I have to do it again? If Amazon offers a feature that is good for its customers, for you, why not offer it in your own online store?

If an order has not yet been shipped or invoiced, what’s the problem in allowing the customer to modify it? And if you have some internal, operational inconvenience, you’d better solve it so that it is not an obstacle to offer this facility to your customers.

Customers make mistakes

Paying with a card

That’s right, customers make mistakes. The checkout process is sometimes not as clear as we think, or on the contrary, it is so efficient at getting the customer to pay that this sometimes causes the customer to speed up and enter the order data wrong.

So there’s nothing wrong with letting your customers know that if they make a mistake they can modify their order before the shipping process begins or the transaction is fully completed.

Customers change their minds

doubting over a purchase

You will tell me that this is a “no thanks”, that how are you going to make it easy for your customers to cancel their orders or remove products from their orders! But as a shop owner, your priority should be your customers, their satisfaction, and above all the confidence that your e-commerce is a safe place to shop online, where the customer always has the last word, and controls the buying process.

You must assume that online shopping customers do not stop seeing similar products while browsing the Internet, and may find similar products cheaper or better, or simply decide to stop an impulse purchase, or whatever the reason for modifying an order(and if they can’t change the order, they will feel cheated).

But don’t just think negatively, the opposite can also happen: your customer may decide to add more products or more quantities to their order.

How do I allow my customers to modify their orders with WooCommerce?

looking for products on a tablet

Okay, you’re already convinced, so let’s get to it, and to achieve this we will use a trick to take advantage of the functionality of WooCommerce to repeat an order, in this case, to create a modification of the existing one.

What the following code does is to add a button to the orders that are still being processed, which, although it indicates that it is to modify the order, it is actually to create a new order, which the customer can modify in the cart and finalize (again) their purchase. To finalize, the previous order is canceled and the new order remains in effect.

It is important that the status of the order is in “Processing”, in order not to send 2 invoices, not to charge 2 times, not to generate problems in the shipments, etc. Of course, all these operations should only be launched in your online store when the order is in “Completed” status, otherwise, you will generate duplicates.

I’m telling you, it’s a bit of a cheat to the system, but it works, which is what matters, isn’t it?

The code is as follows:

/* Modify order button */
// 1. We allow reorder status for orders in process.
add_filter( 'woocommerce_valid_order_statuses_for_order_again', 'wphelp_reorder_again' );
function wphelp_reorder_again( $statuses ) {
$statuses[] = 'processing';
return $statuses;
// 2. We add the actions of the order to the account
add_filter( 'woocommerce_my_account_my_orders_actions', 'wphelp_order_actions', 50, 2 );
function wphelp_order_actions( $actions, $order ) {
if ( $order->has_status( 'processing' ) ) {
$actions['edit-order'] = array(
'url' => wp_nonce_url( add_query_arg( array( 'order_again' => $order->get_id(), 'edit_order' => $order->get_id() ) ), 'woocommerce-order_again' ),
'name' => __( 'Modify order', 'woocommerce' )
return $actions;
// 3. Detect the action of the modified order
add_action( 'woocommerce_cart_loaded_from_session', 'wphelp_detect_modified_order' );
function wphelp_detect_modified_order( $cart ) {
if ( isset( $<em>GET['edit</em>order'], $<em>GET['</em>wpnonce'] ) && is_user_logged_in() && wp_verify_nonce( wp_unslash( $_GET['<em>wpnonce'] ), 'woocommerce-order</em>again' ) ) WC()->session->set( 'edit_order', absint( $<em>GET['edit</em>order'] ) );
// 4. Show notice in the cart that this is a modified order
add_action( 'woocommerce_before_cart', 'wphelp_show_modified_order_notice' );
function wphelp_show_modified_order_notice() {
if ( ! is_cart() ) return;
$edited = WC()->session->get('edit_order');
if ( ! empty( $edited ) ) {
$order = new WC_Order( $edited );
$credit = $order->get_total();
wc_print_notice( 'You have a credit of ' . wc_price($credit) . ' applied to the order. Add products or change details of the order and finish it.', 'notice' );
// 5. Calculate new modified order total
add_action( 'woocommerce_cart_calculate_fees', 'wphelp_calculate_new_order_price', 20, 1 );
function wphelp_calculate_new_order_price( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
$edited = WC()->session->get('edit_order');
if ( ! empty( $edited ) ) {
$order = new WC_Order( $edited );
$credit = -1 * $order->get_total();
$cart->add_fee( 'Credit', $credit );
// 6. Save order if modified
add_action( 'woocommerce_checkout_update_order_meta', 'wphelp_save_modified_order' );
function wphelp_save_modified_order( $order_id ) {
$edited = WC()->session->get( 'edit_order' );
if ( ! empty( $edited ) ) {
// We update this new order
update_post_meta( $order_id, '_edit_order', $edited );
$neworder = new WC_Order( $order_id );
$oldorder_edit = get_edit_post_link( $edited );
$neworder->add_order_note( 'Order made following a modification. Old order number: <a href="' . $oldorder_edit . '">' . $edited . '</a>' );
// cancel previous order
$oldorder = new WC_Order( $edited );
$neworder_edit = get_edit_post_link( $order_id );
$oldorder->update_status( 'cancelled', 'Canceled order following a modification. New order number: <a href="' . $neworder_edit . '">' . $order_id . '</a> -' );
WC()->session->set( 'edit_order', null );
}Code language: PHP (php)

How do I add the code?

This code should be added to your online store created with WooCommerce as you prefer. Here is a tutorial with several ways to add codes to your website:

How and where to paste in WordPress PHP, JS, CSS codes and functions you find out there.

How does the new order modification feature work?

Do you want to see how it works? It seems logical to me, not everyone knows how to read code, and besides, what the hell, we are visual animals, we need to see to create, right?

To begin with, the customer will see a new button in his account page of your online store from which he can modify his orders that are in “Processing” status.

When the customer clicks on the new “Modify order” button, he is redirected to the cart, with messages indicating that a new order has been generated, which he can modify as he wishes, and most importantly, with a credit in his favor for the amount he has already paid(in case he already paid and the total amount is lower than what was paid already). In this way your payment remains valid, but if you add products and increase the amount, you will have to pay the difference – a perfect plan!

Remade cart

At the end of the purchase, with the changes you have made, the customer will see the confirmation of the new/modified order and in his account, the customer will be able to see the canceled and modified order, as well as the history of his orders and the status of his purchases.

new order made

Additionally, in the notes of the orders, notes will be created indicating the process carried out, in order to be able to make all the follow-up in case of need.

And obviously, check that it works on your store before implementing it, we never know if some other code or plugin that you have on your store can interfere with this.

Did you like it, are you going to add this feature to your online store and do you think it is a competitive advantage? Leave your impressions below in the comments

How useful was this post?

Click on a smiley to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top