Skip to content

Commit a4edbed

Browse files
authored
Merge pull request #344 - Alert customer when key configuration is missi
[ch10558] Alert customer when key configuration is missing
2 parents 764a1cd + bb8be80 commit a4edbed

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

woocommerce/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
2019.nn.nn - version 5.4.2-dev.1
44
* Tweak - Add replacement helper methods to get the current screen in WordPress and check the screen ID
55
* Misc - Change SV_WC_Payment_Gateway::is_configured() from protected to public
6+
* Misc - Add admin notice when a gateway is enabled but is not configured and is unable to take payments
67

78
2019.08.06 - version 5.4.1
89
* Misc - Add a configurable admin notice for plugins running deprecated WooCommerce versions

woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,9 @@ public function add_delayed_admin_notices() {
568568

569569
// add notices about enabled debug logging
570570
$this->add_debug_setting_notices();
571+
572+
// add notices about gateways not being configured
573+
$this->add_gateway_not_configured_notices();
571574
}
572575

573576

@@ -723,6 +726,25 @@ protected function add_debug_setting_notices() {
723726
}
724727

725728

729+
/**
730+
* Adds notices about gateways not being configured.
731+
*
732+
* @since 5.4.2-dev.1
733+
*/
734+
protected function add_gateway_not_configured_notices() {
735+
736+
foreach ( $this->get_gateways() as $gateway ) {
737+
738+
if ( $gateway->is_enabled() && ! $gateway->is_configured() && ! $gateway->inherit_settings() ) {
739+
740+
$this->get_admin_notice_handler()->add_admin_notice( $gateway->get_not_configured_error_message(), $gateway->get_id() . '-not-configured', [
741+
'notice_class' => 'error',
742+
] );
743+
}
744+
}
745+
}
746+
747+
726748
/** Integration methods ***************************************************/
727749

728750

woocommerce/payment-gateway/class-sv-wc-payment-gateway.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4152,6 +4152,27 @@ public function get_checkout_order_received_order_id() {
41524152
}
41534153

41544154

4155+
/**
4156+
* Returns the error message for display if the gateway is not configured.
4157+
*
4158+
* @since 5.4.2-dev.1
4159+
*
4160+
* @return string
4161+
*/
4162+
public function get_not_configured_error_message() {
4163+
4164+
return sprintf(
4165+
/* translators: %1$s - gateway name, %2$s - <a> tag, %3$s - </a> tag, %4$s - <a> tag, %5$s - </a> tag */
4166+
__( 'Heads up! %1$s is not fully configured and cannot accept payments. Please %2$sreview the documentation%3$s and configure the %4$sgateway settings%5$s.', 'woocommerce-plugin-framework' ),
4167+
$this->get_method_title(),
4168+
'<a href="' . $this->get_plugin()->get_documentation_url() . '" target="_blank">',
4169+
'</a>',
4170+
'<a href="' . $this->get_plugin()->get_settings_url( $this->get_id() ) . '">',
4171+
'</a>'
4172+
);
4173+
}
4174+
4175+
41554176
/** Deprecated Methods ********************************************************************************************/
41564177

41574178

0 commit comments

Comments
 (0)