Example #1
0
 /**
  * Get html for the MyParcel options
  *
  * @param TIG_MyParcel2014_Model_Shipment $myParcelShipment
  *
  * @return string
  */
 public function getCurrentOptionsHtml($myParcelShipment)
 {
     $options = array($this->__(ucfirst(str_replace('_', ' ', $myParcelShipment->getShipmentType()))));
     if ($myParcelShipment->getShipmentType() == 'normal') {
         if ($myParcelShipment->getHomeAddressOnly() == '1') {
             $options[] = $this->__('Home address only');
         }
         if ($myParcelShipment->getHomeAddressOnly() == '1') {
             $options[] = $this->__('Signature on receipt');
         }
         if ($myParcelShipment->getReturnIfNoAnswer() == '1') {
             $options[] = $this->__('Return if no answer');
         }
         if ($myParcelShipment->getInsuredAmount() > 0) {
             $options[] = $this->__('Insured up to €%s', $myParcelShipment->getInsuredAmount());
         }
         if ($myParcelShipment->getIsXL() == '1') {
             $options[] = $this->__('Large package');
         }
     }
     $htmlOptions = $this->__('status_' . $myParcelShipment->getStatus()) . ', ' . strtolower(implode(', ', $options));
     return $htmlOptions;
 }
Example #2
0
 /**
  * Gets the product code parameters for this shipment.
  *
  * @param TIG_MyParcel2014_Model_Shipment $myParcelShipment
  *
  * @return array
  */
 protected function _getOptionsData(TIG_MyParcel2014_Model_Shipment $myParcelShipment)
 {
     /**
      * Add the shipment type parameter.
      */
     switch ($myParcelShipment->getShipmentType()) {
         case $myParcelShipment::TYPE_LETTER_BOX:
             $packageType = 2;
             break;
         case $myParcelShipment::TYPE_UNPAID:
             $packageType = 3;
             break;
         case $myParcelShipment::TYPE_NORMAL:
         default:
             $packageType = 1;
     }
     $data = array('package_type' => $packageType, 'large_format' => (int) $myParcelShipment->isXL(), 'only_recipient' => (int) $myParcelShipment->isHomeAddressOnly(), 'signature' => (int) $myParcelShipment->isSignatureOnReceipt(), 'return' => (int) $myParcelShipment->getReturnIfNoAnswer(), 'label_description' => $myParcelShipment->getOrder()->getIncrementId());
     $checkoutData = json_decode($myParcelShipment->getOrder()->getMyparcelData(), true);
     if ($checkoutData !== null) {
         if ($checkoutData['time'][0]['price_comment'] !== null) {
             switch ($checkoutData['time'][0]['price_comment']) {
                 case 'morning':
                     $data['delivery_type'] = self::TYPE_MORNING;
                     break;
                 case 'standard':
                     $data['delivery_type'] = self::TYPE_STANDARD;
                     break;
                 case 'night':
                     $data['delivery_type'] = self::TYPE_NIGHT;
                     break;
             }
             if ($checkoutData['date'] !== null) {
                 $checkoutDateTime = $checkoutData['date'] . ' 00:00:00';
                 if (date_parse($checkoutDateTime) >= new dateTime()) {
                     $data['delivery_date'] = $checkoutDateTime;
                 }
                 $dateTime = date_parse($checkoutData['date']);
                 $data['label_description'] = $data['label_description'] . ' (' . $dateTime['day'] . '-' . $dateTime['month'] . ')';
             }
         } elseif ($checkoutData['price_comment'] !== null) {
             switch ($checkoutData['price_comment']) {
                 case 'retail':
                     $data['delivery_type'] = self::TYPE_RETAIL;
                     break;
                 case 'retailexpress':
                     $data['delivery_type'] = self::TYPE_RETAIL_EXPRESS;
                     break;
             }
         }
     }
     if ((int) $myParcelShipment->getInsured() === 1) {
         $data['insurance']['amount'] = $this->_getInsuredAmount($myParcelShipment) * 100;
         $data['insurance']['currency'] = 'EUR';
     }
     if ($myParcelShipment->getShippingAddress()->getCountry() != 'NL') {
         // strip all Dutch domestic options if shipment is not NL
         unset($data['only_recipient']);
         unset($data['signature']);
         unset($data['return']);
         unset($data['delivery_type']);
         unset($data['delivery_date']);
     }
     return $data;
 }