Example #1
0
 /**
  * Edits the shipping method of the order
  * @param TinyBrick_OrderEdit_Model_Order $order
  * @param array $data
  * @return string 
  */
 public function edit(TinyBrick_OrderEdit_Model_Order $order, $data = array())
 {
     $array = array();
     $orderStatus = $order->getStatus();
     $oldMethod = $order->getShippingDescription() . " - \$" . substr($order->getShippingAmount(), 0, -2);
     if ($data['customcarrier'] != '' && $data['rateid'] == 'custom') {
         $order->setShippingMethod('custom');
         $order->setShippingDescription($data['customcarrier'] . " - " . $data['customMethod']);
     } else {
         if ($data['rateid'] != 'custom') {
             $shippingRate = Mage::getModel('orderedit/order_address_rate')->getCollection()->addFieldToFilter('rate_id', $data['rateid'])->getFirstItem();
             $order->setShippingMethod($shippingRate->getCode());
             $order->setShippingDescription($shippingRate->getCarrierTitle() . " - " . $shippingRate->getMethodTitle());
         }
     }
     if ($data['customPrice'] != '') {
         $order->setShippingAmount($data['customPrice']);
         $order->setBaseShippingAmount($data['customPrice']);
     } else {
         if ($data['rateid'] != 'custom') {
             $order->setShippingAmount($shippingRate->getPrice());
         }
     }
     try {
         $order->save();
         //$newMethod = $order->getShippingDescription()." - $".substr($order->getShippingAmount(),0,-2);
         $newMethod = $order->getShippingDescription() . " - \$" . $order->getShippingAmount;
         $results = strcmp($oldMethod, $newMethod);
         if ($results != 0) {
             $comment = "Changed shipping method:<br />";
             $comment .= "Changed FROM: " . $oldMethod . " TO: " . $newMethod . "<br /><br />";
             return $comment;
         }
         return true;
     } catch (Exception $e) {
         $array['status'] = 'error';
         $array['msg'] = "Error updating shipping method";
         return false;
     }
     return true;
 }
Example #2
0
 /**
  * Edits the status of the order
  * @param TinyBrick_OrderEdit_Model_Order $order
  * @param array $data
  * @return string 
  */
 public function edit(TinyBrick_OrderEdit_Model_Order $order, $data = array())
 {
     $array = array();
     $oldStatus = $order->getStatusLabel();
     if ($data['status_id'] != '') {
         $order->setStatus($data['status_id']);
     }
     try {
         $order->save();
         $newStatus = $order->getStatusLabel();
         $results = strcmp($oldStatus, $newStatus);
         if ($results != 0) {
             $comment = "Changed Status:<br />";
             $comment .= "Changed FROM: " . $oldStatus . " TO: " . $newStatus . "<br /><br />";
             return $comment;
         }
         return true;
     } catch (Exception $e) {
         $array['status'] = 'error';
         $array['msg'] = "Error updating status";
         return false;
     }
     return true;
 }
Example #3
0
 /**
  * Logs comment to the order
  * @param TinyBrick_OrderEdit_Model_Order $order
  * @param string $comment Comment appended to order
  * @param string $status Status of order
  * @param int $notify Notify customer
  */
 public function logComment(TinyBrick_OrderEdit_Model_Order $order, $comment, $status, $notify = 0)
 {
     $order->addStatusToHistory($status, $comment, $notify);
     $order->save();
 }