Add tracking of .com ecommerce wpcom plan

[MAILPOET-5628]
This commit is contained in:
Pavel Dohnal
2023-10-04 14:01:22 +02:00
committed by Aschepikov
parent ee199e95a8
commit 0e4e5db1f1
2 changed files with 17 additions and 11 deletions

View File

@ -40,6 +40,10 @@ class DotcomHelperFunctions {
return function_exists('wc_calypso_bridge_is_ecommerce_trial_plan') && wc_calypso_bridge_is_ecommerce_trial_plan();
}
public function isEcommerceWPCom(): bool {
return function_exists('wc_calypso_bridge_is_wpcom_ecommerce_plan') && wc_calypso_bridge_is_wpcom_ecommerce_plan();
}
/**
* Returns the plan name for the current site if hosted on WordPress.com.
* Empty otherwise.
@ -47,20 +51,16 @@ class DotcomHelperFunctions {
public function getDotcomPlan(): string {
if ($this->isWooExpressPerformance()) {
return 'performance';
}
if ($this->isWooExpressEssential()) {
} elseif ($this->isWooExpressEssential()) {
return 'essential';
}
if ($this->isBusiness()) {
} elseif ($this->isBusiness()) {
return 'business';
}
if ($this->isEcommerceTrial()) {
} elseif ($this->isEcommerceTrial()) {
return 'ecommerce_trial';
}
} elseif ($this->isEcommerceWPCom()) {
return 'ecommerce_wpcom';
} else {
return '';
}
}
}

View File

@ -48,4 +48,10 @@ class DotcomHelperFunctionsTest extends \MailPoetUnitTest {
$dotcomHelper->method('isEcommerceTrial')->willReturn(true);
expect($dotcomHelper->getDotcomPlan())->equals('ecommerce_trial');
}
public function testItReturnsEcommerceWPComIfEcommerceWPCom() {
$dotcomHelper = $this->createPartialMock(DotcomHelperFunctions::class, ['isEcommerceWPCom']);
$dotcomHelper->method('isEcommerceWPCom')->willReturn(true);
expect($dotcomHelper->getDotcomPlan())->equals('ecommerce_wpcom');
}
}