Hi Anyone knows how to change Pay button on checkout based on chosen payment method? I found something but I don\'t know if I could turn it into a snippet in function.php? T
add_filter('woocommerce_order_button_text', 'custom_order_button_text' );
function custom_order_button_text( $order_button_text ) {
$default = __( 'Place order', 'woocommerce' ); // If needed
// Get the chosen payment gateway (dynamically)
$chosen_payment_method = WC()->session->get('chosen_payment_method');
## --- For TESTING raw output on the chosen gateway ID --- ##
// echo '' . $chosen_payment_method . '
'; // <=== uncomment for testing
// Set your payment gateways IDs in EACH "IF" statement
if( $chosen_payment_method == 'bacs'){
// HERE set your custom button text
$order_button_text = __( 'Bank wire payment', 'woocommerce' );
} elseif( $chosen_payment_method == 'ecpay_shipping_pay'){
// HERE set your custom button text
$order_button_text = __( 'Place order via Market', 'woocommerce' );
} elseif( $chosen_payment_method == 'ecpay'){
// HERE set your custom button text
$order_button_text = __( 'Place order via ATM/Credit Card', 'woocommerce' );
}
// jQuery code: Make dynamic text button "on change" event ?>
and this is the payment in that dropdown.
'ecpay_payment_methods' => array(
'title' => __( 'Payment Method', 'ecpay' ),
'type' => 'multiselect',
'description' => __( 'Press CTRL and the right button on the mouse to select multi payments.', 'ecpay' ),
'options' => array(
'Credit' => $this->get_payment_desc('Credit'),
'Credit_3' => $this->get_payment_desc('Credit_3'),
'Credit_6' => $this->get_payment_desc('Credit_6'),
'Credit_12' => $this->get_payment_desc('Credit_12'),
'Credit_18' => $this->get_payment_desc('Credit_18'),
'Credit_24' => $this->get_payment_desc('Credit_24'),
'WebATM' => $this->get_payment_desc('WebATM'),
'ATM' => $this->get_payment_desc('ATM'),
'CVS' => $this->get_payment_desc('CVS'),
'BARCODE' => $this->get_payment_desc('BARCODE'),
'ApplePay' => $this->get_payment_desc('ApplePay')
),