当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Event_Observer::getShipment方法代码示例

本文整理汇总了PHP中Varien_Event_Observer::getShipment方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getShipment方法的具体用法?PHP Varien_Event_Observer::getShipment怎么用?PHP Varien_Event_Observer::getShipment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Event_Observer的用法示例。


在下文中一共展示了Varien_Event_Observer::getShipment方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: shipmentSaveBefore

 public function shipmentSaveBefore(Varien_Event_Observer $observer)
 {
     /* @var $shipment Mage_Sales_Model_Order_Shipment */
     $shipment = $observer->getShipment();
     if ($shipment->getOrder()->getDcOrderId() && !$shipment->getDcOrderId()) {
         $result = Dutycalculator_Charge_Model_Importdutytaxes::shipmentCalculation($shipment);
         if ($result) {
             $shipment->setDcOrderId($result['dc_order_id']);
         }
     }
     $shipment->setDeliveryDutyType($shipment->getOrder()->getDeliveryDutyType());
     $shipment->setFailedCalculation($shipment->getOrder()->getFailedCalculation());
     return $this;
 }
开发者ID:Fishead-Communications,项目名称:dutycalculator_charge_import_duty,代码行数:14,代码来源:Observer.php

示例2: sendShipment

 /**
  * Sends create order shipment request to Rakuten Checkout
  * Observes "sales_order_shipment_save_before" event
  *
  * @param  Varien_Event_Observer $observer
  * @return void
  */
 public function sendShipment($observer)
 {
     try {
         /** @var $shipment Mage_Sales_Model_Order_Shipment */
         $shipment = $observer->getShipment();
         if ($shipment->getOrder()->getRakutenOrder()) {
             /** @var $rockout Rakuten_Checkout_Model_Checkout */
             $rockout = Mage::getModel('rakuten/checkout');
             // Send shipment to Rakuten
             $rockout->sendShipment($shipment);
         }
     } catch (Exception $e) {
         Mage::throwException(Mage::helper('rakuten')->__('Cannot send shipment to Rakuten Checkout.') . '<br />' . Mage::helper('rakuten')->__('Error #%s: %s', $e->getCode(), $e->getMessage()));
     }
 }
开发者ID:rakuten-deutschland,项目名称:checkout-magento,代码行数:22,代码来源:Observer.php

示例3: manipulateShipmentForBillsafe

 /**
  * @param Varien_Event_Observer $observer
  *
  * @return $this|void
  */
 public function manipulateShipmentForBillsafe(Varien_Event_Observer $observer)
 {
     if (Mage::getConfig()->getModuleConfig('Netresearch_Billsafe')->is('active', 'true')) {
         $shipment = $observer->getShipment();
         $code = $shipment->getOrder()->getPayment()->getMethodInstance()->getCode();
         if ($code != Netresearch_Billsafe_Model_Payment::CODE) {
             return;
         }
         $magentoShopgateOrder = Mage::getModel("shopgate/shopgate_order")->load($shipment->getOrder()->getId(), "order_id");
         if ($magentoShopgateOrder->getId() == null) {
             return;
         }
         /**
          * manipulate order number
          */
         $shipment->getOrder()->setIncrementId($magentoShopgateOrder->getShopgateOrderNumber());
         /** @var Mage_Sales_Model_Order $order */
         $order = $shipment->getOrder();
         $order->setIsShopgateOrder(true);
         return $this;
     }
     return $this;
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:28,代码来源:Observer.php

示例4: saveConsignmentOption

 /**
  * Saves the chosen consignment options and creates a MyParcel shipment for the current shipment.
  *
  * @param Varien_Event_Observer $observer
  *
  * @return $this
  * @throws Exception
  * @event sales_order_shipment_save_after
  * @observer tig_myparcel_shipment_save_after
  */
 public function saveConsignmentOption(Varien_Event_Observer $observer)
 {
     $helper = Mage::helper('tig_myparcel');
     /**
      * check if extension is enabled
      */
     if (!$helper->isEnabled()) {
         return $this;
     }
     /**
      * @var Mage_Sales_Model_Order_Shipment $shipment
      */
     $shipment = $observer->getShipment();
     /**
      * check if order is placed with Myparcel
      */
     $shippingMethod = $shipment->getOrder()->getShippingMethod();
     if (!$helper->shippingMethodIsMyParcel($shippingMethod)) {
         return $this;
     }
     /**
      * check if the current shipment already has a myparcel shipment
      */
     if ($helper->hasMyParcelShipment($shipment->getId())) {
         return $this;
     }
     /**
      * check if a new consignment must me made
      */
     $registryOptions = Mage::registry('tig_myparcel_consignment_options');
     if (empty($registryOptions) || !isset($registryOptions['create_consignment'])) {
         return $this;
     }
     /**
      * check if consignment option matches the Magento shipment
      */
     if (false !== $helper->getPgAddress($shipment->getOrder()) && (!isset($registryOptions['shipment_type']) || $registryOptions['shipment_type'] != TIG_MyParcel2014_Model_Shipment::TYPE_NORMAL)) {
         return $this;
     }
     /**
      * @var TIG_MyParcel2014_Model_Shipment $myParcelShipment
      */
     $myParcelShipment = Mage::getModel('tig_myparcel/shipment')->load($shipment->getId());
     $consignmentOptions = $registryOptions;
     if (Mage::registry('tig_myparcel_consignment_options')) {
         $consignmentOptions = array_merge($consignmentOptions, Mage::registry('tig_myparcel_consignment_options'));
         Mage::unregister('tig_myparcel_consignment_options');
     }
     Mage::register('tig_myparcel_consignment_options', $consignmentOptions);
     $myParcelShipment->setShipmentId($shipment->getId())->setConsignmentOptions()->createConsignment()->save();
     $barcode = $myParcelShipment->getBarcode();
     if ($barcode) {
         $carrierCode = TIG_MyParcel2014_Model_Shipment::MYPARCEL_CARRIER_CODE;
         $carrierTitle = Mage::getStoreConfig('carriers/' . $carrierCode . '/name', $shipment->getStoreId());
         //if the other carrier-method is used, get the title
         if ($helper->getPgAddress($myParcelShipment)) {
             $carrierTitle = Mage::getStoreConfig('carriers/' . $carrierCode . '/pakjegemak_title', $shipment->getStoreId());
         }
         $data = array('carrier_code' => $carrierCode, 'title' => $carrierTitle, 'number' => $barcode);
         /**
          * @var Mage_Sales_Model_Order_Shipment_Track $track
          */
         $track = Mage::getModel('sales/order_shipment_track')->addData($data);
         $shipment->addTrack($track);
         $trackCollection = $shipment->getTracksCollection();
         foreach ($trackCollection as $track) {
             $track->save();
         }
     }
     return $this;
 }
开发者ID:myparcelnl,项目名称:magento1,代码行数:81,代码来源:SaveShipment.php

示例5: captureInvoiceOnShipment

 /**
  * @param Varien_Event_Observer $observer
  */
 public function captureInvoiceOnShipment(Varien_Event_Observer $observer)
 {
     /* @noinspection PhpUndefinedMethodInspection */
     /* @var Mage_Sales_Model_Order_Shipment $shipment */
     $shipment = $observer->getShipment();
     /** @var Mage_Sales_Model_Order $order */
     $order = $shipment->getOrder();
     $adyenHelper = Mage::helper('adyen');
     $storeId = $order->getStoreId();
     $captureOnShipment = $adyenHelper->getConfigData('capture_on_shipment', 'adyen_abstract', $storeId);
     $createPendingInvoice = $adyenHelper->getConfigData('create_pending_invoice', 'adyen_abstract', $storeId);
     // validate if payment method is adyen and if capture_on_shipment is enabled
     if ($this->isPaymentMethodAdyen($order) && $captureOnShipment) {
         if ($createPendingInvoice) {
             $transaction = Mage::getModel('core/resource_transaction');
             $transaction->addObject($order);
             foreach ($order->getInvoiceCollection() as $invoice) {
                 /* @var Ho_Invoice_Model_Sales_Order_Invoice $invoice */
                 if (!$invoice->canCapture()) {
                     continue;
                 }
                 $invoice->capture();
                 $invoice->setCreatedAt(now());
                 $transaction->addObject($invoice);
             }
             $order->setIsInProcess(true);
             $transaction->save();
         } else {
             // create an invoice and do a capture to adyen
             if ($order->canInvoice()) {
                 try {
                     $invoice = $order->prepareInvoice();
                     $invoice->getOrder()->setIsInProcess(true);
                     // set transaction id so you can do a online refund from credit memo
                     $invoice->setTransactionId(1);
                     $invoice->register()->capture();
                     $invoice->save();
                 } catch (Exception $e) {
                     Mage::logException($e);
                 }
                 $invoiceAutoMail = (bool) $adyenHelper->getConfigData('send_invoice_update_mail', 'adyen_abstract', $storeId);
                 if ($invoiceAutoMail) {
                     $invoice->sendEmail();
                 }
             }
         }
     }
     return $this;
 }
开发者ID:miltoncff,项目名称:magento,代码行数:52,代码来源:Observer.php

示例6: addShippingMethod

 /**
  * Add shipping method to invoice notes.
  *
  * @param  Varien_Event_Observer $observer observer object
  *
  * @return FireGento_Pdf_Model_Observer
  */
 public function addShippingMethod(Varien_Event_Observer $observer)
 {
     $invoice = $observer->getInvoice();
     $shipment = $observer->getShipment();
     if (empty($invoice) && empty($shipment) || !empty($invoice) && Mage::getStoreConfig('sales_pdf/invoice/shipping_method_position') != FireGento_Pdf_Model_System_Config_Source_Shipping::POSITION_NOTE || !empty($shipment) && Mage::getStoreConfig('sales_pdf/shipment/shipping_method_position') != FireGento_Pdf_Model_System_Config_Source_Shipping::POSITION_NOTE) {
         return $this;
     }
     $result = $observer->getResult();
     $notes = $result->getNotes();
     $notes[] = Mage::helper('firegento_pdf')->__('Shipping method: %s', $observer->getOrder()->getShippingDescription());
     $result->setNotes($notes);
     return $this;
 }
开发者ID:codedge,项目名称:firegento-pdf,代码行数:20,代码来源:Observer.php

示例7: handleShipmentSaveBefore

 /**
  * Event
  * - sales_order_shipment_save_before
  *
  * @param Varien_Event_Observer $observer
  * @return $this
  */
 public function handleShipmentSaveBefore(Varien_Event_Observer $observer)
 {
     /* @var $shipment Mage_Sales_Model_Order_Shipment */
     $shipment = $observer->getShipment();
     $carrier = $shipment->getOrder()->getShippingCarrier();
     if ($carrier instanceof Swisspost_YellowCube_Model_Shipping_Carrier_Rate && $shipment->getOrder()->getIsInProcess()) {
         Mage::getModel('shipping/shipping')->requestToShipment($shipment);
     }
     return $this;
 }
开发者ID:swisspost-yellowcube,项目名称:magento-yellowcube,代码行数:17,代码来源:Observer.php

示例8: salesOrderShipmentSaveAfter

 public function salesOrderShipmentSaveAfter(Varien_Event_Observer $observer)
 {
     Mage::getModel('aramexshipping/shipping')->prepareShipment($observer->getShipment(), 'neutral');
 }
开发者ID:TusharKDonda,项目名称:maruti,代码行数:4,代码来源:Observer.php

示例9: _checkInsuranceOfMassActionShipment

 /**
  * Check if insurance is choosen but not possible.
  *
  * @param Varien_Event_Observer $observer
  *
  * @return boolean
  */
 protected function _checkInsuranceOfMassActionShipment($observer)
 {
     $amount = 0;
     foreach ($observer->getShipment()->getItemsCollection() as $item) {
         $amount += (double) $item->getPrice() * (double) $item->getQty();
     }
     return (double) $amount <= (double) Dhl_Intraship_Model_Shipment::INSURANCE_A;
 }
开发者ID:igorvasiliev4,项目名称:magento_code,代码行数:15,代码来源:Observer.php


注:本文中的Varien_Event_Observer::getShipment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。