• 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.

    • This topic was modified 2 years, 9 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_action not working for woocommerce’ is closed to new replies.