• Resolved shadrix

    (@shadrix)


    I’m trying to add a button after the pay now button in WooCommerce.

    This is my current code

    add_action( 'woocommerce_pay_order_after_submit', 'wpastra_return_to_cart_link' );
    function wpastra_return_to_cart_link(){
    
        $button_text = __('Back to cart', 'woocommerce');
    
        $cart_link = WC()->cart->get_cart_url();
    
        echo '<a href="' . $cart_link . '" class="button wc-forward">' . $button_text . '</a>';
    }

    I’m not sure why it’s not working. I have just two plugins active. WooCommerce and Astra as the Theme.

    Any ideas?

    Just to test my code out, I have change the action name to: “woocommerce_review_order_after_submit”. It works but it’s the wrong spot. I want to have it under the button pay now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook Community group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution and the above resources for developers were helpful. If you have further questions, please feel free to open a new topic.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_action not working for woocommerce – add a button after the pay now button’ is closed to new replies.