I’m new to magento and as far as I can see, the order states are labeled as "pending", "processing" and "completed". When customer checks out, then the state becomes "pending", and either invoicing or shipping makes the state "processing", and when both are done, state becomes "completed". Please correct me if I am wrong.
So, I’d like to introduce new states but not statuses, I did manage to introduce new statuses when it is in one of the states above, or I could change the labels of the existing states but I want to learn how magento manages the states and how to modify it/add new states. I can modify the core code if required.
So, my question is how do I introduce new states (not statuses) or how do I change/modify the order life-cycle?
I can investigate the source if you tell me which parts of the code is managing the order life-cycle. Any help or clue is appreciated.
PS: I'm using开发者_JAVA百科 v1.5.1.0 right now.
So in your config.xml you would have something like ...
<config>
<global>
<sales>
<order>
<states>
<my_state translate="label">
<label>My State</label>
<statuses>
<pending default="1"/>
</statuses>
<visible_on_front/>
</my_state>
</states>
</order>
</sales>
</global>
</config>
Then whenever you want the state to change you could override the core or add an observer to change the state (please don't edit the core directly!) with something like (assuming $order
is a valid order already loaded and ready to go) ....
$order->setState("my_state");
$order->save();
which will do the default status for the state. if you want to set a status put that in the second parameter so ..
$order->setState("my_state","complete");
$order->save();
HTH
精彩评论