Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tax_display_type parameter to storeConfig #36

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/Controller/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,24 @@ class Router extends BaseRouter
const XML_PATH_CMS_HOME_PAGE = 'web/default/cms_home_page';
const XML_PATH_THEME_USER_AGENT = 'design/theme/ua_regexp';
const XML_PATH_CATALOG_DEFAULT_SORT_BY = 'catalog/frontend/default_sort_by';
const XML_PATH_TAX_DISPLAY_TYPE = 'tax/display/type';

const PAGE_TYPE_PRODUCT = 'PRODUCT';
const PAGE_TYPE_CATEGORY = 'CATEGORY';
const PAGE_TYPE_CMS_PAGE = 'CMS_PAGE';

const TAX_DISPLAY_TYPE_CONFIG_KEY = 'tax_display_type';

const CRUCIAL_STORE_CONFIG_VALUES = [
'cms_home_page' => self::XML_PATH_CMS_HOME_PAGE,
'catalog_default_sort_by' => self::XML_PATH_CATALOG_DEFAULT_SORT_BY
'catalog_default_sort_by' => self::XML_PATH_CATALOG_DEFAULT_SORT_BY,
'tax_display_type' => self::XML_PATH_TAX_DISPLAY_TYPE
];

const DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX = 'DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX';
const DISPLAY_PRODUCT_PRICES_IN_CATALOG_EXCL_TAX = 'DISPLAY_PRODUCT_PRICES_IN_CATALOG_EXCL_TAX';
const DISPLAY_PRODUCT_PRICES_IN_CATALOG_BOTH = 'DISPLAY_PRODUCT_PRICES_IN_CATALOG_BOTH';

/**
* @var ValidationManagerInterface
*/
Expand Down Expand Up @@ -456,6 +464,10 @@ protected function setStoreConfigs(ActionInterface $action)
$storeConfig[$configKey] = $configValue;
}

if (isset($storeConfig[self::TAX_DISPLAY_TYPE_CONFIG_KEY])) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please move this logic to foreach block, so it we kind of won't be needed to override it after it. Otherwise a bit of magic from first look.

$storeConfig[self::TAX_DISPLAY_TYPE_CONFIG_KEY] = $this->convertTaxDisplayTypeValue($storeConfig[self::TAX_DISPLAY_TYPE_CONFIG_KEY]);
}

$action->setStoreConfig($storeConfig);
}

Expand Down Expand Up @@ -660,5 +672,22 @@ protected function _checkShouldBeSecure(RequestInterface $request, $path = '')
$this->_performRedirect($url);
}
}

/**
* @param String $value
* @return String
*/
protected function convertTaxDisplayTypeValue($value)
{
$result = self::DISPLAY_PRODUCT_PRICES_IN_CATALOG_BOTH;

if ($value === '1') {
$result = self::DISPLAY_PRODUCT_PRICES_IN_CATALOG_EXCL_TAX;
} elseif ($value === '2') {
$result = self::DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX;
}

return $result;
}
}