Support » Plugin: WooCommerce » Need a purchase button/link that checks out

  • Resolved stepan32320

    (@stepan32320)


    So I built a landing page, and everything is ready besides the way to purchase the product. I have buttons and stuff I made using elementor, but I can’t seem to figure out how to direct the customer to a checkout page after pressing the button. I have woocomerce and I made a product for what I want to sell, but it’s just inconvenient because then the customer would have to click ‘buy now’ on the landing page, then it would take them to the product, then add the product to their cart, then checkout, then actually buy. It adds too many steps and too much resistance. Anyone know how I can do this?
    I want to make it so that once you click the “buy now” button on the landing page, it takes the customer to some sort of checkout where they put their information in.
    Thanks!

Viewing 15 replies - 1 through 15 (of 15 total)
  • Felipe Loureiro dos Santos

    (@felipeloureirosantos)

    Hi there,

    You will need clean the user cart when it goes using this link.

    Please put this code on your function.php:

    add_action( 'init', 'woocommerce_clear_cart_url' );
    function woocommerce_clear_cart_url() {
        if ( isset( $_GET['clear-cart'] ) ) {
            global $woocommerce;
            $woocommerce->cart->empty_cart();
        }
    }

    Then you can do it using ?clear-cart&add-to-cart=ID on the end of your checkout page URL. Please change the ID text to your product id.

    stepan32320

    (@stepan32320)

    Thank you! So it works most of the time, but just not all the time. For example, sometimes it just takes me to the page and tells me there’s nothing in my cart (I experience this most on my phone, the link it takes me to is mywebstite.com/cart instead of mywebsite.com/clear-cartadd-to-cart674/).
    Any suggestions on how to get it working flawlessly?

    Plugin Support Fernando

    (@fhaps)

    Automattic Happiness Engineer

    Hi @stepan32320,

    Another way to do this without messing up with the code would be by using a custom add-to-cart link, and a plugin.

    You can create an Add-to-cart link by adding the following string to the end of your store’s domain: ?add-to-cart=PRODUCT_ID (replacing PRODUCT_ID with the actual ID of your product).

    So, if you point the button to that URL, after customers click on that button the product will be added to their cart automatically.

    Then, I’d recommend using the WooCommerce Add to Cart Redirect extension. This plugin lets you configure a redirect – a page customers are taken to after adding a product to their cart. So, you’d only have to configure this page to be the Checkout page. That way, when customers click your custom add-to-cart button:

    1) The product is automatically added to their cart.
    2) They are automatically sent to the checkout page, without them seeing the cart page first.

    Hopefully that helps!

    @fhaps, it’s a good reply.
    Quick question: is wp org allowing affiliate links now?

    Felipe Loureiro dos Santos

    (@felipeloureirosantos)

    @stepan32320 Are you sure that you are using the right link there?

    @fhaps It is important to the user clean the cart before as well as it may increase the product quantity in case you don’t do it first. This way it will always increase the amount when the user access this link.

    Plugin Support Fernando

    (@fhaps)

    Automattic Happiness Engineer

    @felipeloureirosantos If that’s part of the workflow they need, yes. What the custom cart link would be doing is just add the product to the cart. If there’s already a product in there, it won’t be removed – the new one would just be added on top.

    @lordspace Not sure about that. The above is not an affiliate link, though. It has a code for reporting purposes, not for earnings.

    There are a couple of options here already, so I’ll be marking this thread as closed now. If you come across any other issues, feel free to open a new one.

    Soo I have to what you’re saying, @fhaps, is I need to pay you $30 to be able to take someone to a checkout page with that plugin? and @felipeloureirosantos yea it’s the right link, I noticed on incognito mode it doesn’t work though. Any idea as to why?

    Hi @stepan32320,

    Do you have your website live or localhost? Maybe if you share your website URL, so we will be able to look into why it is not working. And maybe provide a different solution.

    You could sill make sure if you are using the right URL, something like that: https://yourwebsite.com/checkout?clear-cart&add-to-cart=ID. Just set the ID and change it to your checkout page slug.

    By the way, you don’t need to pay anything, @fhaps just provided a great and easy solution. If you don’t like it, so try different ways as the one I provided above. You could also search for other plugins or open a topic on different forums and groups.

    My website url is Profitsocialmarketing.com and the landing page is profitsocialmarketing.com/deeper-marketing . When I click on the button with my computer, it adds the product to cart no problem and proceeds to checkout. But on any other device or on incognito mode it doesn’t add it. I added the code you told me to changed the checkout page link to https://profitsocialmarketing.com/clear-cartadd-to-cart674
    am i missing anything? And I originally copy+pasted your thin with the “=” and everything but it just changes it to that.

    Hi there,

    Yes, you are doing it the wrong way.

    Please change your WooCommerce checkout slug to checkout.

    Then, change your “GET YOUR E-BOOK NOW” and “I’LL TAKE THE E-BOOK” to the following link: https://profitsocialmarketing.com/checkout?clear-cart&add-to-cart=674.

    The checkout URL must not change. You just have to add these parameters into it on your landing page. It might fix your problem.

    Hey @felipeloureirosantos. So I just did that. Make my checkout slug “checkout” and changed the link to the buttons to “https://profitsocialmarketing.com/checkout?clear-cart&add-to-cart=674”
    Check it out.
    Now it doesn’t clear the cart and keeps adding more, and it adds 2 on the initial click

    Hey, I just provided the wrong URL, sorry for that.

    Please just change your lading page URL to this one:

    https://profitsocialmarketing.com/checkout/?clear-cart&add-to-cart=674

    Besides that, install Code Snippets and put this code on this plugin:

    add_action( 'init', 'woocommerce_clear_cart_url' );
    function woocommerce_clear_cart_url() {
        if ( isset( $_GET['clear-cart'] ) ) {
            global $woocommerce;
            $woocommerce->cart->empty_cart();
        }
    }

    You could also just put this on functions.php, but make sure that you are using a child theme in this case.

    You could also just import this file into Code Snippets so you won’t need put the code manually.

    @felipeloureirosantos Now it’s working great man! Thank you so much for everything!!!

    Great! Happy that it worked. 🙂

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.