コード例 #1
0
ファイル: Checkout.php プロジェクト: ksaltik/tooldexlive
 /**
  * Sets address data from exported address
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @param array $exportedAddress
  */
 protected function _setExportedAddressData($address, $exportedAddress)
 {
     foreach ($exportedAddress->getExportedKeys() as $key) {
         $oldData = $address->getDataUsingMethod($key);
         $isEmpty = null;
         if (is_array($oldData)) {
             foreach ($oldData as $val) {
                 if (!empty($val)) {
                     $isEmpty = false;
                     break;
                 }
                 $isEmpty = true;
             }
         }
         if (empty($oldData) || $isEmpty === true) {
             $address->setDataUsingMethod($key, $exportedAddress->getData($key));
         }
     }
 }
コード例 #2
0
 /**
  * Checks the shipping address is equal with billing address
  *
  * ATTENTION!!!
  * It should be removed when mobile app will send just the 'use_for_shipping' flag
  * instead of send shipping address same as a billing address
  *
  * @todo Remove when mobile app will send just the 'use_for_shipping' flag
  * @param array $data
  * @param Mage_Sales_Model_Quote_Address $billingAddress
  * @param integer $shippingAddressId
  * @return bool
  */
 protected function _checkUseForShipping(array $data, $billingAddress, $shippingAddressId)
 {
     $useForShipping = !$shippingAddressId || $billingAddress->getId() == $shippingAddressId;
     if ($useForShipping) {
         foreach ($data as $key => $value) {
             if ($key == 'save_in_address_book') {
                 continue;
             }
             $billingData = $billingAddress->getDataUsingMethod($key);
             if (is_array($value) && is_array($billingData)) {
                 foreach ($value as $k => $v) {
                     if (!isset($billingData[$k]) || $billingData[$k] != trim($v)) {
                         $useForShipping = false;
                         break;
                     }
                 }
             } else {
                 if (is_string($value) && $billingData != trim($value)) {
                     $useForShipping = false;
                     break;
                 } else {
                     $useForShipping = false;
                     break;
                 }
             }
         }
     }
     return $useForShipping;
 }
コード例 #3
0
 /**
  * Sets address data from exported address
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @param array $exportedAddress
  */
 protected function _setExportedAddressData($address, $exportedAddress)
 {
     // Exported data is more priority if we came from Express Checkout button
     $isButton = (bool) $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON);
     if (!$isButton) {
         foreach ($exportedAddress->getExportedKeys() as $key) {
             $oldData = $address->getDataUsingMethod($key);
             $isEmpty = null;
             if (is_array($oldData)) {
                 foreach ($oldData as $val) {
                     if (!empty($val)) {
                         $isEmpty = false;
                         break;
                     }
                     $isEmpty = true;
                 }
             }
             if (empty($oldData) || $isEmpty === true) {
                 $address->setDataUsingMethod($key, $exportedAddress->getData($key));
             }
         }
     } else {
         foreach ($exportedAddress->getExportedKeys() as $key) {
             $data = $exportedAddress->getData($key);
             if (!empty($data)) {
                 $address->setDataUsingMethod($key, $data);
             }
         }
     }
 }