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:
Alex P 2023-02-26 15:03:41 +02:00
parent 8640d3031d
commit 38a8473e57
No known key found for this signature in database
GPG key ID: 54487A734A204D71
2 changed files with 1 additions and 26 deletions

View file

@ -972,7 +972,7 @@ class SmartButton implements SmartButtonInterface {
$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';
}

View file

@ -105,31 +105,6 @@ class SettingsStatus {
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.
*