I have seen email templates to use built-in custom variables. Can someone explain how to use
System -> Other Settings -> Custom Variables? For example category count, which will show in frontend.
From what I have used custom variable, it is only for passing admin manageable value to your code, you can access it as follows;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $model = $objectManager->get('Magento\Variable\Model\Variable')->loadByCode('custom-variable-code'); $plain_value = $model->getPlainValue();
Reminder that you should not use objectmanager directly in your code
But where they come in handy is that custom variables can be used in CMS style content. So pages, blocks and email templates.
This is really helpful let's say if you've got a custom telephone number that's different from store number or similar you want to come through in templates.
You should be able to insert using WYSIWYG
You would be surprised how often I see someone insert content manually which could be handled like this.
With some code change you could get these variables to come through on printed invoices etc.
Once all in place custom variable value can then be edited within admin.