PressTigers

How to Add a Quick Buy Link in WooCommerce without a Plugin

WooCommerce being the most popular eCommerce plugin lets you create, manage and maintain an e-commerce store based on WordPress. Sometimes, you might need to insert a quick link to buy a product in WooCommerce custom template. Especially, in the case of subscription products.

In such cases, you can let your customers/users to bypass some extra steps of the checkout process such as:

  • Add to Cart
  • Go to Cart Page
  • Then go to Checkout page for Payment

With the help of a single click (quick buy link/button), you can redirect your customer directly to the cart/checkout page for payment. You just need to add the following code for redirecting customer to the cart page:

Use this code as:

<a href=”<?php echo home_url(‘/cart/?add-to-cart=’.$product_id);?>”>Buy Now</a>

Here, cart is the slug of WooCommerce Cart page and $product_id is the WooCommerce product ID.

Add the following code for redirecting customer to the checkout page:

Use this code as:

<a href=”<?php echo home_url(‘/checkout/?add-to-cart=’.$product_id);?>”>Buy Now</a>

Here, checkout is the slug of WooCommerce Checkout Page and $product_id is the WooCommerce product ID.

User Comments

11 thoughts on “How to Add a Quick Buy Link in WooCommerce without a Plugin

    Arshad Tharani says:

    Thank you for the shortcode. Where exactly should we place this shortcode?
    <a href=””>Buy Now

    I am to show it next to Add to Cart button.

      Hello Arshad,

      You have to put this code into your woo template. If you don’t know where this template, follow the below steps:

      1) Copy the templates from Woo commerce folder to your currently active theme (Parent or Child witch one you have activated)

      2) Search the “Buy Now” button from those templates (single product or product listing Page)

      3) Insert this code right in the next of that “Buy Now” button

      Thanks for reaching us out. Let us know if you need any other assistance from us.

      Regards,

      Abdullah | WP Plugin Developer
      Email: support@presstigers.com

      Grant says:

      Thanks for the article. This works perfectly for my needs!!!

      Not only is it a standalone “quick buy now” link/button to checkout, but it lets me use my own button image 😀

      By the way, I had to uncheck the following option in Woocommerce settings –> Products: “Redirect to the cart page after successful addition”. Otherwise, the url for checkout will send the user to cart.

    Cavid Muradov says:

    This method doesnt work for variable products? How can I add support for variable products?

    Chandan Soni says:

    Hy I am also add this short code . But I can’t do I didn’t understand how to paste this shot code where .
    I want to show Buy Now next to add to cart button .
    Please tell me step by step because I don’t knowledge about cpanel .
    Thank you

      Hello Chandan,

      Everything is clearly listed. If you don’t have the idea about the technical tools then we recommend you please take help from a programmer.

      You can also contact us at support@presstigers.com for availing our services at a cost $24/hour.

      Regards,
      PressTigers Support Team

    william says:

    doesn’t work for variable products as in products with options that change the price does not work with this. It says please choose product options and does not add item to cart.

      william says:

      So i found if you add &variation_id=### where ### is the variation id number found in the woocommerce variation setting
      so just use the right variation with these ur parameters use:

      ?add-to-cart=###&variation_id=###

    faisal.ramzan@nxb.com.pk says:

    Dear William,
    We’re glad that you found the solution. So followings are the updated codes for variation products:

    For Cart Page:

    For Checkout Page:

    Regards,
    Faisal Ramzan | WP Plugin Developer
    Email: support@presstigers.com

      Derik says:

      Thank you for this great solution folks. However, for some reason, it doesn’t work on my end.

      I added this code:

      <a href=””>Buy Now

      into next to Add to Cartd button code in my php file.
      Could you please suggest what the issue might be?

      Nomi says:

      Not working on variable products, Please Help me

Leave a Reply

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

Get in Touch