2

I have a requirement where I need to add my custom discount block only if the discount module is enabled from backend. I can obviously add it in using getStoreConfig() values, but I need to know is it possible to add IFCONFIG in our modules etc/config.xml file ?

Below is my sample config.xml file code but somehow its not working.

<global>
    <sales>
          <quote>
                <totals>
                    <testing ifconfig="mysettings/foo/sayhello"> 
                        <class>NameSpace_ModuleName_Model_Testing</class>
                        <after>subtotal</after>
                    </testing>
                </totals>
            </quote>
     </sales>
</global>

1 Answer 1

3

The ifconfig attribute only works in certain layout XML definitions, not in config XML files

You would have to go with your idea of checking with getStoreConfig() in your custom class.

It is possible to inject custom XML values conditionally at run-time, but there is no good place for it at the moment so the best idea would be to override the core config model and pass your own version into the bootstrapper in index.php (meaning this also has to be done for all shell/external scripts)

When we're on the subject of quote totals and the <after> tag, make sure you don't have any other third party modules or admin settings that modify the sort order and gives you unexpected results. You might need to specify <before> as well, together with multiple comma-separated totals codes in both.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.