コード例 #1
0
 /**
  * @return bool
  */
 protected function _useMercadoEnvios()
 {
     if (empty($this->_useMercadoEnvios)) {
         $quote = $this->shipmentHelper->getQuote();
         $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
         $this->_useMercadoEnvios = $this->shipmentHelper->isMercadoEnviosMethod($shippingMethod);
     }
     return $this->_useMercadoEnvios;
 }
コード例 #2
0
 /**
  * @param \Magento\Framework\Event\Observer $observer
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $observerData = $observer->getData();
     $orderId = $observerData['orderId'];
     $shipmentData = $observerData['shipmentData'];
     $order = $this->coreModel->_getOrder($orderId);
     $method = $order->getShippingMethod();
     if ($this->shipmentHelper->isMercadoEnviosMethod($method)) {
         $methodId = $shipmentData['shipping_option']['shipping_method_id'];
         $name = $shipmentData['shipping_option']['name'];
         $order->setShippingMethod('mercadoenvios_' . $methodId);
         $estimatedDate = $this->_timezone->formatDate($shipmentData['shipping_option']['estimated_delivery']['date']);
         $estimatedDate = __('(estimated date %1)', $estimatedDate);
         $shippingDescription = 'MercadoEnvíos - ' . $name . ' ' . $estimatedDate;
         $order->setShippingDescription($shippingDescription);
         try {
             $order->save();
             $this->shipmentHelper->log('Order ' . $order->getIncrementId() . ' shipping data set ', $shipmentData);
         } catch (\Exception $e) {
             $this->shipmentHelper->log("error when update shipment data: " . $e);
             $this->shipmentHelper->log($e);
         }
     }
 }
コード例 #3
0
 /**
  * @param \Magento\Shipping\Block\Adminhtml\View $subject
  */
 public function beforeGetBackUrl(\Magento\Shipping\Block\Adminhtml\View $subject)
 {
     if ($subject->getRequest()->getFullActionName() == 'adminhtml_order_shipment_view' && $this->_shipmentHelper->isMercadoEnviosMethod($subject->getShipment()->getOrder()->getShippingMethod())) {
         $subject->addButton('custom_button', ['label' => 'Print shipping label', 'onclick' => 'window.open(\' ' . $this->_shipmentHelper->getTrackingPrintUrl($subject->getRequest()->getParam('shipment_id')) . '\')', 'class' => 'go']);
     }
 }