문제

Hello StackExchange community.

Apologise in advance for being vague on this question. However, here we go.

I have a custom sales attribute called 'notes' this is a short description of the shipping method selected by the user. I have built a small module that saves these notes to the quote and then in turn coverts them to the order once the purchase has been made. This works fine for frontend payments. When creating an admin payment, everything works as far as the custom attribute being added the sales_flat_quote table. However, it then doesn't convert it to the order.

I am using the following in my config.xml to handle it :

           <fieldsets>
            <sales_convert_quote>
                <notes><to_order>*</to_order></notes>
            </sales_convert_quote>
           </fieldsets>

As stated this works fine for frontend orders but does not convert on admin payments. Does anyone have any idea why? Is there something over than sales_convert_quote i could try ? Any point in the direction would be greatly appreciated. I'll be happy to post more of the code if it's helpful however i don't think it's necessary since this is the only party of the process that's broken.

Thanks in advance for any help.

도움이 되었습니까?

해결책

Incase someone stumbles across this question and may have been having the same issue i was. I have a resolution however, the problem was not what i thought it was. sales_convert_quote is fine. The problem was the dispatch event that I was using was adding the additional information to the sales_flat_quote table after sales_convert_quote is called.

I just had to change the dispatch event i was using to add the information to the quote table when the ajax for switching shipping methods is called. For your reference here is my config xml

<adminhtml>
        <events>
            <core_block_abstract_to_html_after>
                <observers>
                    <admin_before_order_save_new>
                        <class>Actioncameras_MatrixToOrder_Model_Observer</class>
                        <method>admin_before_order_save</method>
                    </admin_before_order_save_new>
                </observers>
            </core_block_abstract_to_html_after>
        </events>
    </adminhtml>

Then in my Model/Observer.php here is my function :

class Packagename_ModuleName_Model_Observer {
    public function admin_before_order_save($observer) {
        if($observer->getEvent()->getBlock()->getNameInLayout() == "shipping_method")
        {
            $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
            $shippingAddress = $quote->getShippingAddress();

            if(!$shippingMethod = $shippingAddress->getShippingMethod())
            {
                return false;
            }

            $shippingRate = $shippingAddress->getShippingRateByCode($shippingMethod);
            $quote->setNotes($shippingRate->getMethodDescription());
            $quote->save();
        }
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top