Merge pull request #2235 from woocommerce/PCP-3091-requirement-user-must-have-seen-a-pay-pal-button-before-using-fastlane

AXO: Force the Paypal button display in Cart before using Fastlane (3091)
This commit is contained in:
Emili Castells 2024-05-23 16:14:48 +02:00 committed by GitHub
commit 7f71e3af26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 98 additions and 5 deletions

View file

@ -61,17 +61,33 @@ $background-ident-color: #fbfbfb;
border: 1px solid #c3c4c7;
border-left-width: 4px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
margin: 5px 0px 2px;
padding: 0px 12px 4px 12px;
margin: 5px 15px 2px 0;
padding: 1px 12px;
p, .form-table td & p {
margin-top: 4px;
margin-bottom: 4px;
}
.highlight {
background: transparent;
font-weight: 600;
}
}
.ppcp-notice-warning {
border-left-color: #dba617;
.highlight {
background: transparent;
color: #dba617;
font-weight: 600;
}
}
.ppcp-notice-error {
border-left-color: #d63638;
.highlight {
color: #d63638;
}
}

View file

@ -65,7 +65,7 @@ return function ( ContainerInterface $container, array $fields ): array {
'type' => 'ppcp-multiselect',
'input_class' => array( 'wc-enhanced-select' ),
'default' => $container->get( 'wcgateway.button.default-locations' ),
'description' => __( 'Select where the PayPal smart buttons should be displayed.', 'woocommerce-paypal-payments' ),
'description' => __( 'Select where the PayPal smart buttons should be displayed.', 'woocommerce-paypal-payments' ) . $container->get( 'axo.smart-button-location-notice' ),
'options' => $container->get( 'wcgateway.button.locations' ),
'screens' => array( State::STATE_START, State::STATE_ONBOARDED ),
'requirements' => array(),

View file

@ -745,4 +745,28 @@ class SettingsListener {
}
}
/**
* Filter settings based on a condition.
*
* @param bool $condition The condition.
* @param string $setting_slug The setting slug.
* @param callable $filter_function The filter function.
* @param bool $persist Whether to persist the settings.
*/
public function filter_settings( bool $condition, string $setting_slug, callable $filter_function, bool $persist = true ): void {
if ( ! $this->is_valid_site_request() || State::STATE_ONBOARDED !== $this->state->current_state() ) {
return;
}
$existing_setting_value = $this->settings->has( $setting_slug ) ? $this->settings->get( $setting_slug ) : null;
if ( $condition ) {
$new_setting_value = $filter_function( $existing_setting_value );
$this->settings->set( $setting_slug, $new_setting_value );
if ( $persist ) {
$this->settings->persist();
}
}
}
}