I have a system.xml file in which i already have retrieved customer groups in a multiselectist field .Now i want to associate one field-To set some value for each customer group.How can i get these values from system.xml when customer clicks "proceed to checkout".And How can i redirect customer to */checkout/cart/ " .
1 Answer
When you save in Configuration, the value of your custom field will save in table "core_config_data" with column path is section_id/group_id/field_id and the column value is what you choose/enter value in your custom field.
To get value of section_id/group_id/field_id, you can use \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig in your constructor argument and set the class property $this->scopeConfig = $scopeConfig;
Now to get the configuration value in your function, just use:
$this->scopeConfig->getValue('section_id/group_id/field_id', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); It's look like this:
public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, ) { $this->scopeConfig = $scopeConfig; } public function yourFunction() { $valueCustomField = $this->scopeConfig->getValue('section_id/group_id/field_id', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); //do something here } - How can i assign each customer group a value from another field in system.xml?Magento beginner– Magento beginner2023-04-04 03:40:26 +00:00Commented Apr 4, 2023 at 3:40
- I think you can use dynamic row. You can read this developer.adobe.com/commerce/php/tutorials/admin/…Shou– Shou2023-04-04 03:47:03 +00:00Commented Apr 4, 2023 at 3:47
- Please answer this "How can i get these values from system.xml when customer clicks "proceed to checkout".And How can i redirect customer to */checkout/cart/ "Magento beginner– Magento beginner2023-04-07 04:39:32 +00:00Commented Apr 7, 2023 at 4:39
