mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
Split is_pay_later_messaging_enabled
This commit is contained in:
parent
a87eba2044
commit
1962823eb3
2 changed files with 13 additions and 7 deletions
|
@ -394,7 +394,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function render_message_wrapper_registrar(): bool {
|
private function render_message_wrapper_registrar(): bool {
|
||||||
if ( ! $this->settings_status->is_pay_later_messaging_enabled() ) {
|
if ( ! $this->settings_status->is_pay_later_messaging_enabled() || ! $this->settings_status->has_pay_later_messaging_locations() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,15 +33,19 @@ class SettingsStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether Pay Later message is enabled either for checkout, cart or product page.
|
* Checks whether Pay Later messaging is enabled.
|
||||||
*
|
|
||||||
* @return bool true if is enabled, otherwise false.
|
|
||||||
*/
|
*/
|
||||||
public function is_pay_later_messaging_enabled(): bool {
|
public function is_pay_later_messaging_enabled(): bool {
|
||||||
$messaging_enabled = $this->settings->has( 'pay_later_messaging_enabled' ) && $this->settings->get( 'pay_later_messaging_enabled' );
|
return $this->settings->has( 'pay_later_messaging_enabled' ) && $this->settings->get( 'pay_later_messaging_enabled' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether any Pay Later messaging location is enabled.
|
||||||
|
*/
|
||||||
|
public function has_pay_later_messaging_locations(): bool {
|
||||||
$selected_locations = $this->settings->has( 'pay_later_messaging_locations' ) ? $this->settings->get( 'pay_later_messaging_locations' ) : array();
|
$selected_locations = $this->settings->has( 'pay_later_messaging_locations' ) ? $this->settings->get( 'pay_later_messaging_locations' ) : array();
|
||||||
|
|
||||||
return $messaging_enabled && ! empty( $selected_locations );
|
return ! empty( $selected_locations );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +55,9 @@ class SettingsStatus {
|
||||||
* @return bool true if is enabled, otherwise false.
|
* @return bool true if is enabled, otherwise false.
|
||||||
*/
|
*/
|
||||||
public function is_pay_later_messaging_enabled_for_location( string $location ): bool {
|
public function is_pay_later_messaging_enabled_for_location( string $location ): bool {
|
||||||
return $this->is_pay_later_messaging_enabled() && $this->is_enabled_for_location( 'pay_later_messaging_locations', $location );
|
return $this->is_pay_later_messaging_enabled() &&
|
||||||
|
$this->has_pay_later_messaging_locations() &&
|
||||||
|
$this->is_enabled_for_location( 'pay_later_messaging_locations', $location );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue