1

I need to add my custom item to Checkout Total Sort Order in configuration page. I created custom price, which shown in checkout according to this manual https://indiestechtips.wordpress.com/2011/07/30/how-to-add-custom-field-in-the-billing-and-shipping-address-of-onepage-checkout-in-magento/ Difference only in that my custom field is calculated via math formula. So now, having new field in checkout, I need to add this field to Checkout Total Sort Order. Question is that how to do this ?

2

add to your extension system.xml

<config>
    <sections>
        <sales>
            <groups>
                <totals_sort>
                    <fields>
                        <yourfield translate="label">
                            <label>Your Field Label</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </yourfield>
                    </fields>
                </totals_sort>
            </groups>
        </sales>
    </sections>
</config>

instend of you need to use your code. ex "discount","grand_total"

Look in to Mage_Sales_Model_Quote_Address_Total_Collector

protected function _initRetrievers()
    {
        $sorts = Mage::getStoreConfig(self::XML_PATH_SALES_TOTALS_SORT, $this->_store);
        foreach ($sorts as $code => $sortOrder) {
            if (isset($this->_models[$code])) {
                // Reserve enough space for collisions
                $retrieverId = 100 * (int) $sortOrder;
                // Check if there is a retriever with such id and find next available position if needed
                while (isset($this->_retrievers[$retrieverId])) {
                    $retrieverId++;
                }
                $this->_retrievers[$retrieverId] = $this->_models[$code];
            }
        }
        ksort($this->_retrievers);
        $notSorted = array_diff(array_keys($this->_models), array_keys($sorts));
        foreach ($notSorted as $code) {
            $this->_retrievers[] = $this->_models[$code];
        }
        return $this;
    }
2
  • Thanks a lot. It works. But I have another question: if I have 1 field with order "10" and my field with order "5", should I expect that my field must be higher that standard field? Or to realize it must be additional code. Feb 24 '16 at 8:20
  • 1
    Updated answer please check it Feb 24 '16 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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