Add changelog and enable promotion in core and plugin configs (https://github.com/woocommerce/woocommerce-admin/pull/7666)
* Add changelog and enable promotion in core and plugin configs * Add PR number * Make variation name a constant * Clone spec as we are overwriting the is_visible prop * Fix unit tests and support array and object * Revert explat variation name * Update changelog entry * Update changelog once more * Make sure the recommendations show up if marketplace suggestions is not defined defaulting to 'yes'
This commit is contained in:
parent
48539bf3f4
commit
da395281e7
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: Enhancement
|
||||
|
||||
Add experiment for promoting WooCommerce Payments in payment methods table. #7666
|
|
@ -19,7 +19,7 @@ const RecommendationsEligibilityWrapper: React.FC = ( { children } ) => {
|
|||
SHOW_MARKETPLACE_SUGGESTION_OPTION,
|
||||
] );
|
||||
const canShowMarketplaceSuggestions =
|
||||
getOption( SHOW_MARKETPLACE_SUGGESTION_OPTION ) === 'yes';
|
||||
getOption( SHOW_MARKETPLACE_SUGGESTION_OPTION ) !== 'no';
|
||||
|
||||
return hasFinishedResolving && canShowMarketplaceSuggestions;
|
||||
} );
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
"store-alerts": true,
|
||||
"tasks": false,
|
||||
"transient-notices": true,
|
||||
"wc-pay-promotion": false
|
||||
"wc-pay-promotion": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
"store-alerts": true,
|
||||
"tasks": false,
|
||||
"transient-notices": true,
|
||||
"wc-pay-promotion": false
|
||||
"wc-pay-promotion": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@ class EvaluateSuggestion {
|
|||
/**
|
||||
* Evaluates the spec and returns the suggestion.
|
||||
*
|
||||
* @param array $spec The suggestion to evaluate.
|
||||
* @return array The evaluated suggestion.
|
||||
* @param object|array $spec The suggestion to evaluate.
|
||||
* @return object The evaluated suggestion.
|
||||
*/
|
||||
public static function evaluate( $spec ) {
|
||||
$rule_evaluator = new RuleEvaluator();
|
||||
$suggestion = (object) $spec;
|
||||
$suggestion = is_array( $spec ) ? (object) $spec : clone $spec;
|
||||
|
||||
if ( isset( $suggestion->is_visible ) ) {
|
||||
$is_visible = $rule_evaluator->evaluate( $suggestion->is_visible );
|
||||
|
|
|
@ -15,7 +15,8 @@ use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\EvaluateSugg
|
|||
* WC Pay Promotion engine.
|
||||
*/
|
||||
class Init {
|
||||
const SPECS_TRANSIENT_NAME = 'woocommerce_admin_payment_method_promotion_specs';
|
||||
const SPECS_TRANSIENT_NAME = 'woocommerce_admin_payment_method_promotion_specs';
|
||||
const EXPLAT_VARIATION_PREFIX = 'woocommerce_wc_pay_promotion_payment_methods_table_';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -113,7 +114,7 @@ class Init {
|
|||
$allow_tracking
|
||||
);
|
||||
|
||||
$variation_name = $abtest->get_variation( 'woocommerce_wc_pay_promotion_payment_methods_table_' . $wc_pay_spec->additional_info->experiment_version );
|
||||
$variation_name = $abtest->get_variation( self::EXPLAT_VARIATION_PREFIX . $wc_pay_spec->additional_info->experiment_version );
|
||||
|
||||
if ( 'treatment' === $variation_name ) {
|
||||
return true;
|
||||
|
|
|
@ -31,7 +31,7 @@ class WC_Tests_PaymentGatewaySuggestions_EvaluateSuggestion extends WC_Unit_Test
|
|||
$suggestion = array(
|
||||
'id' => 'mock-gateway',
|
||||
);
|
||||
$evaluated = EvaluateSuggestion::evaluate( $suggestion );
|
||||
$evaluated = EvaluateSuggestion::evaluate( (object) $suggestion );
|
||||
$this->assertEquals( (object) $suggestion, $evaluated );
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class WC_Tests_PaymentGatewaySuggestions_EvaluateSuggestion extends WC_Unit_Test
|
|||
'operation' => '=',
|
||||
),
|
||||
);
|
||||
$evaluated = EvaluateSuggestion::evaluate( $suggestion );
|
||||
$evaluated = EvaluateSuggestion::evaluate( (object) $suggestion );
|
||||
$this->assertFalse( $evaluated->is_visible );
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ class WC_Tests_PaymentGatewaySuggestions_EvaluateSuggestion extends WC_Unit_Test
|
|||
),
|
||||
);
|
||||
update_option( self::MOCK_OPTION, 'a' );
|
||||
$evaluated = EvaluateSuggestion::evaluate( $suggestion );
|
||||
$evaluated = EvaluateSuggestion::evaluate( (object) $suggestion );
|
||||
$this->assertTrue( $evaluated->is_visible );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue