Public Member Functions | |
runTest () | |
getOrder () | |
matchOrderStatus ($type, $status) | |
validateOrderStatus () | |
getOrderActions () | |
getAdminStatus () | |
getFrontendStatus () | |
Protected Attributes | |
$_order |
Definition at line 5 of file test.php.
getAdminStatus | ( | ) |
getFrontendStatus | ( | ) |
getOrderActions | ( | ) |
Available actions for admin user
Definition at line 193 of file test.php.
00194 { 00195 $actions = array(); 00196 00197 $actions['comment'] = 1; 00198 00199 if ($this->matchOrderStatus('order', 'cancelled')) { 00200 $actions['reorder'] = 1; 00201 return $actions; 00202 } 00203 00204 if ($this->matchOrderStatus('order', 'closed')) { 00205 $actions['reorder'] = 1; 00206 if (!$this->matchOrderStatus('refund', 'refunded')) { 00207 $actions['creditmemo'] = 1; 00208 } 00209 return $actions; 00210 } 00211 00212 if ($this->matchOrderStatus('order', 'onhold')) { 00213 $actions['unhold'] = 1; 00214 return $actions; 00215 } 00216 00217 $actions['edit'] = 1; 00218 00219 $actions['hold'] = 1; 00220 00221 if (!$this->matchOrderStatus('order', 'void')) { 00222 $actions['cancel'] = 1; 00223 } 00224 00225 if ($this->matchOrderStatus('payment', 'not_authorized')) { 00226 $actions['authorize'] = 1; 00227 $actions['capture'] = 1; 00228 } 00229 00230 if (!$this->matchOrderStatus('payment', 'not_authorized,pending,paid')) { 00231 $actions['invoice'] = 1; 00232 } 00233 00234 00235 if (!$this->matchOrderStatus('shipping', 'shipped')) { 00236 $actions['ship'] = 1; 00237 } 00238 00239 if ($this->matchOrderStatus('payment', 'partial,paid') && !$this->matchOrderStatus('refund', 'refunded')) { 00240 $actions['creditmemo'] = 1; 00241 } 00242 00243 if ($this->matchOrderStatus('order', 'void')) { 00244 unset($actions['ship'], $actions['invoice'], $actions['ship'], $actions['hold']); 00245 } 00246 00247 return $actions; 00248 }
matchOrderStatus | ( | $ | type, | |
$ | status | |||
) |
Check if type and status matches for the order
string | $type order, payment, shipment | |
string | $status comma separated
|
Definition at line 83 of file test.php.
00083 { 00084 $statuses = explode(',', $status); 00085 $value = $this->getOrder()->getData($type.'_status'); 00086 foreach ($statuses as $status) { 00087 if ($value==$status) { 00088 return true; 00089 } 00090 } 00091 return false; 00092 }
runTest | ( | ) |
Definition at line 8 of file test.php.
00009 { 00010 $this->_order = new Varien_Object; 00011 #echo "<table border=1><tr><td>Order</td><td>Payment</td><td>Shipping</td><td>Refund</td><td>Return</td><td>Admin Status</td><td>Frontend Status</td><td>Actions</td></tr>"; 00012 echo "<table border=1><tr><td>Order</td><td>Payment</td><td>Refund</td><td>Shipping</td><td>Actions</td></tr>"; 00013 foreach (array('new', 'onhold', 'processing', 'complete', 'closed', 'cancelled', 'void') as $orderStatus) { 00014 $this->getOrder()->setOrderStatus($orderStatus); 00015 foreach (array('not_authorized', 'pending', 'authorized', 'partial', 'paid') as $paymentStatus) { 00016 $this->getOrder()->setPaymentStatus($paymentStatus); 00017 foreach (array('pending', 'partial', 'shipped') as $shippingStatus) { 00018 $this->getOrder()->setShippingStatus($shippingStatus); 00019 foreach (array('not_refunded', 'partial', 'refunded') as $refundStatus) { 00020 $this->getOrder()->setRefundStatus($refundStatus); 00021 // foreach (array('not_returned', 'partial', 'returned') as $returnStatus) { 00022 // $this->getOrder()->setReturnStatus($returnStatus); 00023 if (!$this->validateOrderStatus()) { 00024 continue; 00025 } 00026 $adminStatus = $this->getAdminStatus(); 00027 $frontendStatus = $this->getFrontendStatus(); 00028 $actions = $this->getOrderActions(); 00029 $actions = join(', ', array_keys($actions)); 00030 #echo "<tr><td>$orderStatus</td><td>$paymentStatus</td><td>$shippingStatus</td><td>$refundStatus</td><td>$returnStatus</td><td>$adminStatus</td><td>$frontendStatus</td><td>$actions</td></tr>"; 00031 echo "<tr><td>$orderStatus</td><td>$paymentStatus</td><td>$refundStatus</td><td>$shippingStatus</td><td>$actions</td></tr>"; 00032 // } 00033 } 00034 } 00035 } 00036 } 00037 echo "</table>"; 00038 }
validateOrderStatus | ( | ) |
Definition at line 94 of file test.php.
00095 { 00096 if ($this->matchOrderStatus('order', 'new')) { 00097 if (!$this->matchOrderStatus('shipping', 'pending') 00098 // || !$this->matchOrderStatus('return', 'not_returned') 00099 || !$this->matchOrderStatus('refund', 'not_refunded') 00100 ) { 00101 return false; 00102 } 00103 if ($this->matchOrderStatus('payment', 'partial')) { 00104 return false; 00105 } 00106 } 00107 00108 if ($this->matchOrderStatus('order', 'onhold')) { 00109 if (!$this->matchOrderStatus('shipping', 'pending') 00110 || !$this->matchOrderStatus('payment', 'pending') 00111 || !$this->matchOrderStatus('refund', 'not_refunded') 00112 // || !$this->matchOrderStatus('return', 'not_returned') 00113 ) { 00114 return false; 00115 } 00116 } 00117 00118 if ($this->matchOrderStatus('order', 'cancelled')) { 00119 if (!$this->matchOrderStatus('shipping', 'pending') 00120 || !$this->matchOrderStatus('payment', 'pending,not_authorized') 00121 || !$this->matchOrderStatus('refund', 'not_refunded') 00122 // || !$this->matchOrderStatus('return', 'not_returned') 00123 ) { 00124 return false; 00125 } 00126 } 00127 00128 if ($this->matchOrderStatus('order', 'complete,closed')) { 00129 if (!$this->matchOrderStatus('payment', 'paid') 00130 || !$this->matchOrderStatus('shipping', 'shipped') 00131 ) { 00132 return false; 00133 } 00134 } 00135 00136 if ($this->matchOrderStatus('order', 'void')) { 00137 if ($this->matchOrderStatus('payment', 'pending,not_authorized')) { 00138 return false; 00139 } 00140 if (!$this->matchOrderStatus('refund', 'not_refunded')) { 00141 return false; 00142 } 00143 } 00144 00145 if ($this->matchOrderStatus('payment', 'pending,not_authorized') 00146 && !$this->matchOrderStatus('refund', 'not_refunded') 00147 ) { 00148 return false; 00149 } 00150 00151 if ($this->matchOrderStatus('payment', 'authorized') 00152 && !$this->matchOrderStatus('refund', 'not_refunded') 00153 ) { 00154 return false; 00155 } 00156 00157 if ($this->matchOrderStatus('payment', 'partial') 00158 && $this->matchOrderStatus('refund', 'refunded') 00159 ) { 00160 return false; 00161 } 00162 00163 // if ($this->matchOrderStatus('shipping', 'pending') 00164 // && !$this->matchOrderStatus('return', 'not_returned') 00165 // ) { 00166 // return false; 00167 // } 00168 // 00169 // if ($this->matchOrderStatus('shipping', 'partial') && $this->matchOrderStatus('return', 'returned')) { 00170 // return false; 00171 // } 00172 00173 return true; 00174 }