← All changes
|
includes/Services/Settings/Payment_Gateways_Section.php
+14
-2
1.10.9
→
1.10.21
View file →
| @@ -7,8 +7,9 @@ | ||
| 7 | 7 | |
| 8 | 8 | namespace WCPOS\WooCommercePOS\Services\Settings; |
| 9 | 9 | |
| 10 | 10 | use WC_Payment_Gateways; |
| 11 | +use WCPOS\WooCommercePOS\Payments\Gateway_Contract; | |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * The Payment Gateways Settings Section. |
| 14 | 15 | * |
| @@ -105,8 +106,10 @@ | ||
| 105 | 106 | |
| 106 | 107 | // Gateways that represent deferred/unverified payment default to on-hold. |
| 107 | 108 | $on_hold_gateways = array( 'bacs', 'cheque' ); |
| 108 | 109 | |
| 110 | + $contract = new Gateway_Contract(); | |
| 111 | + | |
| 109 | 112 | // loop through installed gateways and merge with saved settings. |
| 110 | 113 | foreach ( $installed_gateways as $id => $gateway ) { |
| 111 | 114 | // sanity check for gateway class. |
| 112 | 115 | if ( ! is_a( $gateway, 'WC_Payment_Gateway' ) || 'pre_install_woocommerce_payments_promotion' === $id ) { |
| @@ -117,10 +120,10 @@ | ||
| 117 | 120 | |
| 118 | 121 | $response['gateways'][ $id ] = array_replace_recursive( |
| 119 | 122 | array( |
| 120 | 123 | 'id' => $gateway->id, |
| 121 | - 'title' => $gateway->title, | |
| 122 | - 'description' => $gateway->description, | |
| 124 | + 'title' => $contract->get_display_title( $gateway ), | |
| 125 | + 'description' => $contract->get_display_description( $gateway ), | |
| 123 | 126 | 'enabled' => false, |
| 124 | 127 | 'order' => 999, |
| 125 | 128 | 'order_status' => $default_status, |
| 126 | 129 | ), |
| @@ -125,8 +128,17 @@ | ||
| 125 | 128 | 'order_status' => $default_status, |
| 126 | 129 | ), |
| 127 | 130 | $gateways_settings['gateways'][ $id ] ?? array() |
| 128 | 131 | ); |
| 132 | + | |
| 133 | + if ( ! is_string( $response['gateways'][ $id ]['title'] ) || '' === trim( $response['gateways'][ $id ]['title'] ) ) { | |
| 134 | + $response['gateways'][ $id ]['title'] = $contract->get_display_title( $gateway ); | |
| 135 | + } | |
| 136 | + | |
| 137 | + // A saved empty string is a deliberate blank and is kept. | |
| 138 | + if ( ! is_string( $response['gateways'][ $id ]['description'] ) ) { | |
| 139 | + $response['gateways'][ $id ]['description'] = $contract->get_display_description( $gateway ); | |
| 140 | + } | |
| 129 | 141 | } |
| 130 | 142 | |
| 131 | 143 | /** |
| 132 | 144 | * Filters the payment gateways settings. |