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.

Categories

Related Blogs

Customize Woocommerce Settings Tab

Let’s talk about customizing Woocommerce Admin setting Tabs.To hide a specific Woocommerce setting tab or want to customize the Woocommerce setting tabs, not the entire sub-menu, but just a tab.For just Removing tabs we can use

Disable Automatic Login After Registration

When we enable customer registration on My Account page, We will know that when new user is register it’s automatically logged in .
it need to change when we need to manually approve each user.

Add Admin User in WordPress By FTP

Creating an admin user in WordPress through an FTP client is not a direct method since user accounts are managed through the WordPress database and not through files on the server. To add an admin user, you’ll need to use a different approach. Here’s how you can do it: