Order Again Button on My Account > Orders WooCommerce

To add an “Order Again” button on the WooCommerce My Account > Orders page, you can use hooks and filters to customize the order details table. The following steps will guide you through the process:

Step 1: Create a Custom Function Add the following code to your theme’s functions.php file or a custom plugin:

// Add "Order Again" button to the "My Account > Orders" page
function custom_add_order_again_button($order_id)
{
    $order = wc_get_order($order_id);

    // Check if the order is valid and if it is "completed" or "processing"
    if ($order && in_array($order->get_status(), array('completed', 'processing'))) {
        $order_again_url = wc_get_cart_url() . '?order_again=' . $order_id;

        echo '<a href="' . esc_url($order_again_url) . '" class="button order-again">' . __('Order Again', 'woocommerce') . '</a>';
    }
}
add_action('woocommerce_my_account_my_orders_actions', 'custom_add_order_again_button');

Step 2: Save Changes and Test Save the changes to your functions.php file or custom plugin. Now, when you visit the “My Account > Orders” page in WooCommerce, you should see an “Order Again” button for each completed or processing order.

The “Order Again” button will allow customers to quickly add the products from the respective order to their cart and proceed to checkout, saving them the effort of manually searching for and adding each product again.

Please note that the “Order Again” button will only be displayed for orders with the “completed” or “processing” status, as these are typically the statuses for orders that have been successfully processed and can be reordered.

Related Blogs

WooCommerce: Add A New Checkout Field.

To add a new checkout field in WooCommerce, you can use the `woocommerce_after_order_notes` action hook to display the new field on the checkout page. Additionally, you’ll need to use the `woocommerce_checkout_process` and `woocommerce_checkout_update_order_meta` filter hooks to handle the validation and saving of the field data.

Ajax login WordPress

Sometime we need to login in site without reloading the page.so we simply use ajax for it. first we add

Request A Quote

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.