• Resolved mobi5965

    (@mobi5965)


    How can we change the order of Amazonpay button on product page? even if have to do with hook.

    Regards.

    • This topic was modified 2 years, 1 month ago by mobi5965.
    • This topic was modified 2 years, 1 month ago by mobi5965.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Christian

    (@christian1983)

    Hey @mobi5965 ,

    Hope you are doing well!

    The button on the single product pages is being defined in file includes\class-wc-gateway-amazon-payments-advanced.php in the method WC_Gateway_Amazon_Payments_Advanced::init_handlers() as add_action( 'woocommerce_single_product_summary', array( $this, 'maybe_separator_and_checkout_button_single_product' ), 30 );

    So in your theme you could implement something like the following:

    <?php
    if ( function_exists( 'wc_apa' ) ) {
        remove_action( 'woocommerce_single_product_summary', array( wc_apa()->get_gateway(), 'maybe_separator_and_checkout_button_single_product' ), 30 );
    
        add_action( 'woocommerce_single_product_summary', array( wc_apa()->get_gateway(), 'maybe_separator_and_checkout_button_single_product' ), 60 );
    
    }

    Where the 60, would mean that it would be printed later but within the same hook woocommerce_single_product_summary. You could decrease or increase that number as he sees fit. You could also choose to use another hook instead of the woocommerce_single_product_summary to output the button.

    Let me know if that helps.

    Best,
    Christian

    Thread Starter mobi5965

    (@mobi5965)

    OK thanks,

    I tried this with “init” and “wp_loaded” but its not working.

    Plugin Support Christian

    (@christian1983)

    Hey @mobi5965

    Here is a refactor of the snippet:

    add_action( 'wp_loaded', function () {
        // Bail early if Amazon Pay plugin inactive.
        if ( ! function_exists( 'wc_apa' ) ) {
            return;
        }
        remove_action( 'woocommerce_single_product_summary', array( wc_apa()->get_gateway(), 'maybe_separator_and_checkout_button_single_product' ), 30 );
        add_action( 'woocommerce_single_product_summary', array( wc_apa()->get_gateway(), 'maybe_separator_and_checkout_button_single_product' ), 60 );
    }, 12 );

    you need to added on the funcions.php of the theme.

    Let me know if that works.

    Would you mind taking a minute to leave your?feedback?on your experience with the plugin? Your insights are incredibly valuable and will help us make sure we serve you and other amazing customers well in the future.

    Thank you for taking the time to share your opinion. It makes such a difference in how we show up and serve others!

    Best,
    Christian

    Thread Starter mobi5965

    (@mobi5965)

    Hi, I have already solved the issue using your previous code in wp_loaded.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change amazon pay button oder product page’ is closed to new replies.