mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-12 01:18:39 +08:00
Fix pay later on order pay page
This commit is contained in:
parent
68569c93f7
commit
8640d3031d
1 changed files with 19 additions and 0 deletions
|
@ -54,6 +54,8 @@ class SettingsStatus {
|
||||||
* @throws NotFoundException When a setting was not found.
|
* @throws NotFoundException When a setting was not found.
|
||||||
*/
|
*/
|
||||||
public function is_pay_later_messaging_enabled_for_location( string $location ): bool {
|
public function is_pay_later_messaging_enabled_for_location( string $location ): bool {
|
||||||
|
$location = $this->normalize_location( $location );
|
||||||
|
|
||||||
if ( ! $this->is_pay_later_messaging_enabled() ) {
|
if ( ! $this->is_pay_later_messaging_enabled() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -88,6 +90,8 @@ class SettingsStatus {
|
||||||
* @throws NotFoundException When a setting was not found.
|
* @throws NotFoundException When a setting was not found.
|
||||||
*/
|
*/
|
||||||
public function is_pay_later_button_enabled_for_location( string $location ): bool {
|
public function is_pay_later_button_enabled_for_location( string $location ): bool {
|
||||||
|
$location = $this->normalize_location( $location );
|
||||||
|
|
||||||
if ( ! $this->is_pay_later_button_enabled() ) {
|
if ( ! $this->is_pay_later_button_enabled() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -133,6 +137,8 @@ class SettingsStatus {
|
||||||
* @return bool true if is enabled, otherwise false.
|
* @return bool true if is enabled, otherwise false.
|
||||||
*/
|
*/
|
||||||
public function is_smart_button_enabled_for_location( string $location ): bool {
|
public function is_smart_button_enabled_for_location( string $location ): bool {
|
||||||
|
$location = $this->normalize_location( $location );
|
||||||
|
|
||||||
$selected_locations = $this->settings->has( 'smart_button_locations' ) ? $this->settings->get( 'smart_button_locations' ) : array();
|
$selected_locations = $this->settings->has( 'smart_button_locations' ) ? $this->settings->get( 'smart_button_locations' ) : array();
|
||||||
|
|
||||||
if ( empty( $selected_locations ) ) {
|
if ( empty( $selected_locations ) ) {
|
||||||
|
@ -141,4 +147,17 @@ class SettingsStatus {
|
||||||
|
|
||||||
return in_array( $location, $selected_locations, true );
|
return in_array( $location, $selected_locations, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapts the context value to match the location settings.
|
||||||
|
*
|
||||||
|
* @param string $location The location/context.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function normalize_location( string $location ): string {
|
||||||
|
if ( 'pay-now' === $location ) {
|
||||||
|
$location = 'checkout';
|
||||||
|
}
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue