• Resolved ndjworldnews

    (@ndjworldnews)


    Hello;

    I am using the variation-add-to-cart-button.php file to display a gift card customers can purchase. I would like to add an additional ‘Buy now’ button below the ‘Add to cart’ button.

    I am using the following code to do this:

    
    <div class="express-checkout-wrapper">
                        <a id="dc_express_checkout" href="/checkout/?add-to-cart=<?php echo get_the_ID(); ?>">
                            <span class="buts">Buy now</span>
                        </a>
                    </div>
    

    The button is created and when clicked on works but does not populate the checkout fields. Instead I get “Private: Checkout” with a button below that to go back to the shopping page.

    What am I missing?

    Any help would be greatly appreciated. Thank you.

    Lode

    • This topic was modified 4 years, 11 months ago by ndjworldnews.
    • This topic was modified 4 years, 11 months ago by ndjworldnews.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    I suggest you use a hook instead: https://rynaldo.com/create-a-second-add-to-cart-button-in-woocommerce/

    **Before you do that, please do make a full backup!**

    Kind regards,

    Thread Starter ndjworldnews

    (@ndjworldnews)

    Hello Con;

    Thanks for your answer. I will try that and see how it goes.

    One way or another I will let you know.

    Lode

    Thread Starter ndjworldnews

    (@ndjworldnews)

    Hello Con;

    Applied the code replacing the template with the one I need. It works wonderfully, except this code, as is clear, adds an additional add to cart button. I want a ‘buy now’ button in addition to the existing add to cart button already in the template.

    How can I modify this code to reflect checkout instead of add to cart?

    Any suggestions?

    Thanks

    Lode

    Thread Starter ndjworldnews

    (@ndjworldnews)

    Well I figured out how to add a buy button on the variable page using this snippet:

    ‘add_action( ‘woocommerce_single_variation’, ‘woocommerce_button_proceed_to_checkout’, 30 );’

    but that only adds the button. When I click on it it routes to a page that reads:

    “Oops that page can’t be found.”

    Equally interesting is the link for the buy button shows mydomain/checkout but when I click on it it routes to mydomain/cart.

    Any assistance would be greatly appreciated.

    Thanks

    Lode

    Remi Corson

    (@corsonr)

    Automattic Happiness Engineer

    Hi, thanks for the heads-up, I’ll mark this as resolved now.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add Buy now button to variable page’ is closed to new replies.