Skip to content

Commit

Permalink
Removes api token from default scope config
Browse files Browse the repository at this point in the history
  • Loading branch information
Calin Reimer authored and CalinR committed Aug 31, 2023
1 parent a87cf6b commit 02c9b80
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
25 changes: 25 additions & 0 deletions Block/System/Config/Form/Field/ApiNote.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Bold\Checkout\Block\System\Config\Form\Field;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;

/**
* Bold Integration api note field.
*/
class ApiNote extends Field
{
/**
* @inheritDoc
*/
protected function _renderValue(AbstractElement $element)
{
$text = __('Please switch website scopes first to add an API Token.');
$element->setText($text);

return parent::_renderValue($element);
}
}
2 changes: 1 addition & 1 deletion Observer/Checkout/CheckoutSectionSave.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function execute(Observer $observer): void
{
$event = $observer->getEvent();
$websiteId = (int)$event->getWebsite();
if (!$this->config->isCheckoutEnabled($websiteId)) {
if (!$this->config->isCheckoutEnabled($websiteId) || $websiteId === 0) {
return;
}
$this->config->setShopId($websiteId, null);
Expand Down
8 changes: 6 additions & 2 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<field id="type">1</field>
</depends>
</field>
<field id="api_token" translate="label" type="obscure" sortOrder="20" showInDefault="1"
<field id="api_token" translate="label" type="obscure" sortOrder="20" showInDefault="0"
showInWebsite="1">
<label>API Token</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
Expand All @@ -47,6 +47,10 @@
Center.
</comment>
</field>
<field id="api_token_note" translate="label" type="note" sortOrder="25" showInDefault="1">
<label>API Token</label>
<frontend_model>Bold\Checkout\Block\System\Config\Form\Field\ApiNote</frontend_model>
</field>
<field id="integration_email" translate="select" type="select" sortOrder="30" showInDefault="1"
showInWebsite="1">
<label>Bold Integration Email</label>
Expand All @@ -64,7 +68,7 @@
<validate>required-entry</validate>
<comment><![CDATA[Please do not change.]]></comment>
</field>
<field id="integration_status" translate="label" type="note" sortOrder="60" showInDefault="1" showInWebsite="1">
<field id="integration_status" translate="label" type="note" sortOrder="60" showInDefault="0" showInWebsite="1">
<label>Bold Integration Status</label>
<frontend_model>Bold\Checkout\Block\System\Config\Form\Field\Status</frontend_model>
<comment><![CDATA[In case the status is 'Not Found', please re-save configuration.
Expand Down

0 comments on commit 02c9b80

Please sign in to comment.