mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Remove redundant method
pay later is not available for mini-cart, and even if we add it we should not implement this check with such confusing naming (location and context)
This commit is contained in:
parent
8640d3031d
commit
38a8473e57
2 changed files with 1 additions and 26 deletions
|
@ -972,7 +972,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
$disable_funding = $all_sources;
|
$disable_funding = $all_sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $this->settings_status->is_pay_later_button_enabled_for_context( $this->context() ) ) {
|
if ( ! $this->settings_status->is_pay_later_button_enabled_for_location( $this->context() ) ) {
|
||||||
$disable_funding[] = 'credit';
|
$disable_funding[] = 'credit';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,31 +105,6 @@ class SettingsStatus {
|
||||||
return in_array( $location, $selected_locations, true );
|
return in_array( $location, $selected_locations, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether Pay Later button is enabled for a given context.
|
|
||||||
*
|
|
||||||
* @param string $context The context.
|
|
||||||
* @return bool true if is enabled, otherwise false.
|
|
||||||
* @throws NotFoundException When a setting was not found.
|
|
||||||
*/
|
|
||||||
public function is_pay_later_button_enabled_for_context( string $context ): bool {
|
|
||||||
if ( ! $this->is_pay_later_button_enabled() ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$selected_locations = $this->settings->has( 'pay_later_button_locations' ) ? $this->settings->get( 'pay_later_button_locations' ) : array();
|
|
||||||
|
|
||||||
if ( empty( $selected_locations ) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$enabled_for_current_location = $this->is_pay_later_button_enabled_for_location( $context );
|
|
||||||
$enabled_for_product = $this->is_pay_later_button_enabled_for_location( 'product' );
|
|
||||||
$enabled_for_mini_cart = $this->is_pay_later_button_enabled_for_location( 'mini-cart' );
|
|
||||||
|
|
||||||
return $context === 'product' ? $enabled_for_product || $enabled_for_mini_cart : $enabled_for_current_location;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether smart buttons are enabled for a given location.
|
* Checks whether smart buttons are enabled for a given location.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue