Skip to content

Commit

Permalink
Support multisite setup (#4)
Browse files Browse the repository at this point in the history
* Update references to Hyvä Checkout

* Enable configuration settings for websites and stores

* Get config values with store scope
  • Loading branch information
fsesini-avery authored Dec 17, 2024
1 parent 7e676e4 commit cfcc303
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Plugin/PickRandomCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Hyva\Checkout\Model\Config;
use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\State;
use Magento\Framework\Serialize\SerializerInterface;

Expand Down Expand Up @@ -36,12 +37,12 @@ public function afterGetActiveCheckoutNamespace(
string $result
): string {
// When the AB test is disabled, use the default configuration
if (!$this->config->getValue(self::HYVA_CHECKOUT_AB_TEST_ENABLED)) {
if (!$this->config->getValue(self::HYVA_CHECKOUT_AB_TEST_ENABLED, ScopeInterface::SCOPE_STORE)) {
return $result;
}

try {
$checkouts = $this->serializer->unserialize($this->config->getValue(self::HYVA_CHECKOUT_AB_TEST_CHECKOUTS));
$checkouts = $this->serializer->unserialize($this->config->getValue(self::HYVA_CHECKOUT_AB_TEST_CHECKOUTS, ScopeInterface::SCOPE_STORE));
} catch (Exception $e) {
$checkouts = [];
}
Expand Down
6 changes: 3 additions & 3 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="hyva_themes_checkout">
<group id="ab_test" translate="label" type="text" sortOrder="15" showInDefault="1" showInWebsite="0" showInStore="0">
<group id="ab_test" translate="label" type="text" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="1">
<label>A/B Test</label>
<field id="enabled" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="enabled" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="checkouts" translate="label" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="checkouts" translate="label" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Checkouts</label>
<frontend_model>Elgentos\HyvaCheckoutABTest\Block\Adminhtml\Form\Field\Checkouts</frontend_model>
<backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
Expand Down

0 comments on commit cfcc303

Please sign in to comment.