Exemple #1
0
 /**
  * Get address for zone calculator
  *
  * @return array
  */
 protected function getAddress()
 {
     $address = null;
     $addressObj = $this->getOrderAddress();
     if ($addressObj) {
         // Profile is exists
         $address = \XLite\Model\Shipping::prepareAddressData($addressObj);
     }
     if (!isset($address)) {
         $address = $this->getDefaultAddress();
     }
     return $address;
 }
 /**
  * Get cache parameters
  *
  * @return array
  */
 protected function getCacheParameters()
 {
     $list = parent::getCacheParameters();
     $auth = \XLite\Core\Auth::getInstance();
     if ($auth->isLogged()) {
         $profile = $auth->getProfile();
         // Membership as a parameter (wholesale and other prices)
         $list[] = $profile->getMembership() ? $profile->getMembership()->getMembershipId() : '-';
         // Shipping address zone as a parameter (taxes amount)
         foreach (\XLite\Core\Database::getRepo('XLite\\Model\\Zone')->findApplicableZones(\XLite\Model\Shipping::prepareAddressData($profile->getShippingAddress())) as $zone) {
             $list[] = $zone->getZoneId();
         }
     }
     // If the cart is changed the widget content must be recalculated
     $list[] = $this->getCart()->getItemsFingerprint();
     // If some of the registered widget/request parameters are changed
     // the widget content must be recalculated
     foreach ($this->defineCachedParams() as $name) {
         $list[] = $this->getRequestParamValue($name) ?: (($widgetParam = $this->getWidgetParams($name)) ? $widgetParam->value : '');
     }
     return $list;
 }
Exemple #3
0
 /**
  * Get shipping address
  * 
  * @return \XLite\Model\Address
  */
 protected function getShippingAddress()
 {
     if (null === static::$shippingAddress) {
         if ($this->hasShippingAddress()) {
             static::$shippingAddress = \XLite\Model\Shipping::prepareAddressData(\XLite::getController()->getCart()->getProfile()->getShippingAddress());
         } else {
             static::$shippingAddress = \XLite\Model\Shipping::getDefaultAddress();
         }
     }
     return static::$shippingAddress;
 }