Business Bloomer
  • About
  • WooCommerce Blog
  • Online Courses
  • Login
  • 0
  • About
  • WooCommerce Blog
  • Online Courses
  • Login
  • 0

WooCommerce: Order Again Button @ My Account > Orders

> Published: Jun 2022
> Blog Category: WooCommerce Tips
> Blog Tags: Add to Cart, My Account, Order
> Blog Comments: 6 Comments
Tweet

Join 17,000+ WooWeekly subscribers

The WooCommerce “Order Again” button displays for ‘completed’ orders on the Thank You page and View Order page. That’s a pity, because it would be useful to show it on the My Account > Orders page as well, as a custom “action”, same as the “View”, “Pay” (if pending), “Cancel” (if subscription), “Edit” (custom snippet), “Confirm” (custom snippet) buttons.

The good news is that we can code it ourselves! And just reuse most of the code we already wrote, as well as rely on the WooCommerce “listener” for the existing “Order Again” button. Enjoy!

Completed orders will now get a custom “Order again” button under My Account > Orders. On click, the Cart will be filled out with the same products that were in the original order.

PHP Snippet: Add “Order Again” Button to My Account > Orders Action (Completed Orders Only)

If you’re wondering how I came up with the ‘url’ code in the snippet below, I simply reused the exact same code of the woocommerce_order_again_button() function.

Also, somewhere in the Cart class, there is a “listener” that triggers when the button is clicked – see get_cart_from_session() – so because I’m using the exact same button URL, the listener triggers from the new button position as well.

/**
 * @snippet       Order Again @ My Account Orders
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_my_account_my_orders_actions', 'bbloomer_order_again_action', 9999, 2 );
   
function bbloomer_order_again_action( $actions, $order ) {
    if ( $order->has_status( 'completed' ) ) {
        $actions['order-again'] = array(
            'url' => wp_nonce_url( add_query_arg( 'order_again', $order->get_id(), wc_get_cart_url() ), 'woocommerce-order_again' ),
            'name' => __( 'Order again', 'woocommerce' ),
        );
    }
    return $actions;
}

Related posts:

  1. WooCommerce: Allow Users to Edit Processing Orders
  2. WooCommerce: Let Customers Complete a Processing Order
  3. WooCommerce: Hide Price & Add to Cart for Logged Out Users
  4. WooCommerce: Add First & Last Name to My Account Register Form
  5. WooCommerce: Add Select Field to “My Account” Register Form
  6. WooCommerce: Check if Product Category is in the Order
  7. WooCommerce: Add Privacy Policy Consent @ My Account Registration
  8. WooCommerce: Deny Automatic Login Upon Registration @ My Account
  9. WooCommerce: Update Order Field Value After a Successful Order
  10. WooCommerce: Sync Billing Name & WP User Name

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

Follow @rmelogli
Category: WooCommerce Tips
Tags: Add to Cart, My Account, Order

Post navigation

Previous post: WooCommerce: 10 Crucial Issues That Should Be Fixed Right Now
Next post: WooCommerce: How To Enable Stripe Payments

6 thoughts on “WooCommerce: Order Again Button @ My Account > Orders”

  1. Nicolas
    October 10, 2022

    Hello Rodolfo, first of all, thanks for this snippet. We have tested this inside an eCommerce website me manage, but somethiing really weird happens after we click on the order again button: it redirects us to the Cart (as I believe it is suppose to be..) but then the cart is empty. Even if I have something in the cart before clicking the order again button (at any order available in my account, inside the Orders Tab).. the Cart gets always emptied. What could we do to solve this issue?

    Reply
    1. Rodolfo Melogli
      October 26, 2022

      A cache issue maybe?

      Reply
  2. michel
    September 2, 2022

    HI there, my client want a option and i hope i can explain it well.

    situation: a client made an order. en later the same client want ot make an order again en then he needs to combine te orde in the checkout. so he want a button ” combine order” then he need to enter his order number of the first order” my client wants this so he can combine it in 1 shipping and the customer only pays 1 shipping. i hope you understand what my client need

    Reply
    1. Rodolfo Melogli
      September 6, 2022

      Hello Michel, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

      Reply
  3. George M
    June 17, 2022

    Hi seems to work but it is next to the view button. how could i add this down from the view button? Thanks

    Reply
    1. Rodolfo Melogli
      June 20, 2022

      Thank you George! A bit of custom CSS would do in this case. Unfortunately this is specific to your theme so I can’t help here.

      Reply
Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Cancel reply

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

Recent Posts
  • WooCommerce: Redirect Product Category Pages
  • WooCommerce: Close Button @ WooCommerce Checkout Notices
  • WooCommerce: Related Products Custom Heading & Subheading
  • WooCommerce: Display Stock Status For External Products
  • WooCommerce: Display Product Grid @ Order Emails e.g. Related Products
About Business Bloomer

With 100,000 (and growing) monthly organic sessions, Business Bloomer is the most consistent, most active and most complete WooCommerce development/customization blog.

Of course this website itself uses the WooCommerce plugin, the Storefront theme and runs on a WooCommerce-friendly hosting.

Join 75,000+ Monthly Readers & 16,500+ Subscribers.

Become a Business Bloomer Supporter.

Join BloomerArmada and become an Official Business Bloomer Supporter:
easy-peasy, and lots of perks for you.
See your Benefits →
Popular Searches: Visual Hook Guides - Checkout Page - Cart Page - Single Product Page - Add to Cart - Emails - Shipping - Prices - Hosting
Latest Articles
  • WooCommerce: Redirect Product Category Pages
  • WooCommerce: Close Button @ WooCommerce Checkout Notices
  • WooCommerce: Related Products Custom Heading & Subheading
  • WooCommerce: Display Stock Status For External Products
  • WooCommerce: Display Product Grid @ Order Emails e.g. Related Products
Latest Comments
  • Rodolfo Melogli on The Ultimate Guide to WooCommerce Coupons
  • Rodolfo Melogli on Account Management & Privacy
  • Gary
    PRIORITY COMMENTER »
    on CustomizeWoo FREE
  • IAN
    PRIORITY COMMENTER »
    on Account Management & Privacy
Find Out More
  • Become a WooCommerce Expert
  • WooCommerce Blog
  • WooCommerce Online Courses
  • WooCommerce Weekly
  • Bloomer Armada
  • Affiliate Program
  • Contact
Contact Info

Ciao! I’m Rodolfo Melogli, an Italian Civil Engineer who has turned into an international WooCommerce expert. You can contact me here:

Email: [email protected]

Twitter: @rmelogli

Hire me by the hour: Get Quote ยป

VisaMastercardAmexPayPal Acceptance Mark
Business Bloomer © 2011-2023 - Terms of Use - Privacy Policy