Skip to content

Commit

Permalink
Do only override gateway order button text in case the gateway has ex…
Browse files Browse the repository at this point in the history
…plicitly set the button text. Added missing class attribute to direct debit.
  • Loading branch information
dennisnissle committed Nov 8, 2023
1 parent d857826 commit e562fe5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 3 additions & 4 deletions includes/class-wc-gzd-payment-gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ public function gateway_supports_fees( $id ) {
}

protected function maybe_force_gateway_button_text( $gateway ) {
if ( ! isset( $gateway->force_order_button_text ) || $gateway->force_order_button_text ) {
$button_text = $gateway->order_button_text;

if ( ! is_null( $button_text ) && ! empty( $button_text ) && ( ! isset( $gateway->force_order_button_text ) || $gateway->force_order_button_text ) ) {
/**
* Filter to adjust the forced order submit button text per gateway.
* By default Woo allows gateways to adjust the submit button text.
Expand All @@ -144,7 +146,6 @@ public function manipulate_gateways() {
$gateways = WC()->payment_gateways()->payment_gateways();

foreach ( $gateways as $gateway ) {

if ( 'yes' !== $gateway->enabled ) {
continue;
}
Expand All @@ -153,7 +154,6 @@ public function manipulate_gateways() {
$this->maybe_force_gateway_button_text( $gateway );

if ( $this->gateway_supports_fees( $gateway->id ) && $gateway->get_option( 'fee' ) ) {

$gateway_description = $this->gateway_data[ $gateway->id ]['description'];
$desc = sprintf( __( '%s payment charge', 'woocommerce-germanized' ), wc_price( $gateway->get_option( 'fee' ) ) ) . '.';

Expand All @@ -171,7 +171,6 @@ public function manipulate_gateways() {
*
*/
$gateway_description .= apply_filters( 'woocommerce_gzd_payment_gateway_description', ' ' . $desc, $gateway );

$gateway->description = $gateway_description;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class WC_GZD_Gateway_Direct_Debit extends WC_Payment_Gateway {

protected $enable_pre_notification;

protected $instructions;

protected $debit_days;

protected $generate_mandate_id;
Expand Down

0 comments on commit e562fe5

Please sign in to comment.