1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Checkout_Model_Type_Multishipping_State extends Varien_Object
35: {
36: const STEP_SELECT_ADDRESSES = 'multishipping_addresses';
37: const STEP_SHIPPING = 'multishipping_shipping';
38: const STEP_BILLING = 'multishipping_billing';
39: const STEP_OVERVIEW = 'multishipping_overview';
40: const STEP_SUCCESS = 'multishipping_success';
41:
42: 43: 44: 45: 46:
47: protected $_steps;
48:
49: 50: 51: 52: 53:
54: protected $_checkout;
55:
56: 57: 58: 59:
60: public function __construct()
61: {
62: parent::__construct();
63: $this->_steps = array(
64: self::STEP_SELECT_ADDRESSES => new Varien_Object(array(
65: 'label' => Mage::helper('checkout')->__('Select Addresses')
66: )),
67: self::STEP_SHIPPING => new Varien_Object(array(
68: 'label' => Mage::helper('checkout')->__('Shipping Information')
69: )),
70: self::STEP_BILLING => new Varien_Object(array(
71: 'label' => Mage::helper('checkout')->__('Billing Information')
72: )),
73: self::STEP_OVERVIEW => new Varien_Object(array(
74: 'label' => Mage::helper('checkout')->__('Place Order')
75: )),
76: self::STEP_SUCCESS => new Varien_Object(array(
77: 'label' => Mage::helper('checkout')->__('Order Success')
78: )),
79: );
80:
81: foreach ($this->_steps as $step) {
82: $step->setIsComplete(false);
83: }
84:
85: $this->_checkout = Mage::getSingleton('checkout/type_multishipping');
86: $this->_steps[$this->getActiveStep()]->setIsActive(true);
87: }
88:
89: 90: 91: 92: 93:
94: public function getCheckout()
95: {
96: return $this->_checkout;
97: }
98:
99: 100: 101: 102: 103:
104: public function getSteps()
105: {
106: return $this->_steps;
107: }
108:
109: 110: 111: 112: 113:
114: public function getActiveStep()
115: {
116: $step = $this->getCheckoutSession()->getCheckoutState();
117: if (isset($this->_steps[$step])) {
118: return $step;
119: }
120: return self::STEP_SELECT_ADDRESSES;
121: }
122:
123: public function setActiveStep($step)
124: {
125: if (isset($this->_steps[$step])) {
126: $this->getCheckoutSession()->setCheckoutState($step);
127: }
128: else {
129: $this->getCheckoutSession()->setCheckoutState(self::STEP_SELECT_ADDRESSES);
130: }
131:
132:
133: if(!$this->_steps[$step]->getIsActive()) {
134: foreach($this->getSteps() as $stepObject) {
135: $stepObject->unsIsActive();
136: }
137: $this->_steps[$step]->setIsActive(true);
138: }
139: return $this;
140: }
141:
142: 143: 144: 145: 146: 147:
148: public function setCompleteStep($step)
149: {
150: if (isset($this->_steps[$step])) {
151: $this->getCheckoutSession()->setStepData($step, 'is_complete', true);
152: }
153: return $this;
154: }
155:
156: 157: 158: 159: 160: 161:
162: public function getCompleteStep($step)
163: {
164: if (isset($this->_steps[$step])) {
165: return $this->getCheckoutSession()->getStepData($step, 'is_complete');
166: }
167: return false;
168: }
169:
170: 171: 172: 173: 174: 175:
176: public function unsCompleteStep($step)
177: {
178: if (isset($this->_steps[$step])) {
179: $this->getCheckoutSession()->setStepData($step, 'is_complete', false);
180: }
181: return $this;
182: }
183:
184: public function canSelectAddresses()
185: {
186:
187: }
188:
189: public function canInputShipping()
190: {
191:
192: }
193:
194: public function canSeeOverview()
195: {
196:
197: }
198:
199: public function canSuccess()
200: {
201:
202: }
203:
204: 205: 206: 207: 208:
209: public function getCheckoutSession()
210: {
211: return Mage::getSingleton('checkout/session');
212: }
213: }
214: