예제 #1
0
 /**
  * Return an object property
  *
  * @access public
  * @param string
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'price':
             return $this->Isotope->calculatePrice($this->getPrice(), $this, 'price', $this->arrData['tax_class']);
             break;
     }
     return parent::__get($strKey);
 }
예제 #2
0
 /**
  * Return an object property
  *
  * @access public
  * @param string
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'price':
             $fltEligibleSubTotal = $this->getAdjustedSubTotal(TL_MODE == 'FE' ? $this->Isotope->Cart->subTotal : $this->Isotope->Order->subTotal);
             return $fltEligibleSubTotal <= 0 ? 0.0 : $this->Isotope->calculatePrice($this->calculateShippingRate($this->id, $fltEligibleSubTotal), $this, 'price', $this->arrData['tax_class']);
         default:
             return parent::__get($strKey);
     }
 }
예제 #3
0
 /**
  * Return an object property
  *
  * @access public
  * @param string
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'available':
             if (!parent::__get('available')) {
                 return false;
             }
             $objOptions = $this->getOptions();
             if (!$objOptions->numRows) {
                 return false;
             }
             return true;
             break;
         case 'price':
             $objOptions = $this->getOptions();
             return $this->Isotope->calculatePrice($objOptions->rate, $this, 'price', $this->arrData['tax_class']);
         default:
             return parent::__get($strKey);
     }
 }
예제 #4
0
 /**
  * Return an object property
  *
  * @access public
  * @param string
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'price':
             $arrSubDivisionShipping = explode(',', $this->Isotope->Cart->shippingAddress['subdivision']);
             $arrDestination = array('name' => $this->Isotope->Cart->shippingAddress['firstname'] . ' ' . $this->Isotope->Cart->shippingAddress['lastname'], 'phone' => $this->Isotope->Cart->shippingAddress['phone'], 'company' => $this->Isotope->Cart->shippingAddress['company'], 'street' => $this->Isotope->Cart->shippingAddress['street_1'], 'street2' => $this->Isotope->Cart->shippingAddress['street_2'], 'street3' => $this->Isotope->Cart->shippingAddress['street_3'], 'city' => $this->Isotope->Cart->shippingAddress['city'], 'state' => $arrSubDivisionShipping[1], 'zip' => $this->Isotope->Cart->shippingAddress['postal'], 'country' => $this->Isotope->Cart->shippingAddress['country']);
             $arrSubDivisionStore = explode(',', $this->Isotope->Config->subdivision);
             $arrOrigin = array('name' => $this->Isotope->Config->firstname . ' ' . $this->Isotope->Config->lastname, 'phone' => $this->Isotope->Config->phone, 'company' => $this->Isotope->Config->company, 'street' => $this->Isotope->Config->street_1, 'street2' => $this->Isotope->Config->street_2, 'street3' => $this->Isotope->Config->street_3, 'city' => $this->Isotope->Config->city, 'state' => $arrSubDivisionStore[1], 'zip' => $this->Isotope->Config->postal, 'country' => $this->Isotope->Config->country);
             $arrShipment['service'] = (int) $this->ups_enabledService < 10 ? "0" . $this->ups_enabledService : $this->ups_enabledService;
             //Ground for now
             $arrShipment['pickup_type'] = array('code' => '03', 'description' => '');
             $fltWeight = $this->Isotope->Cart->getShippingWeight('lb');
             $arrShipment['packages'][] = array('packaging' => array('code' => '02', 'description' => ''), 'description' => '', 'units' => 'LBS', 'weight' => ceil($fltWeight));
             // set object properties
             $this->server = 'https://www.ups.com/ups.app/xml/Rate';
             $this->shipment = $arrShipment;
             $this->shipper = $arrOrigin;
             //FOR NOW, This is assumed to be the same for origin and shipping info
             $this->ship_from = $arrOrigin;
             //FOR NOW, This is assumed to be the same for origin and shipping info.  Could be used to ship from multiple fulfillment places, drop shipping, etc.
             $this->destination = $arrDestination;
             return ($this->arrData['price'] ? $this->price : 0) + $this->calculateShippingRate();
             break;
     }
     return parent::__get($strKey);
 }
예제 #5
0
 /**
  * Return an object property
  *
  * @access public
  * @param string
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'price':
             /*$arrDestination = array
             		(
             			'name'			=> $this->Isotope->Cart->shippingAddress['firstname'] . ' ' . $this->Isotope->Cart->shippingAddress['lastname'],
             			'phone'			=> $this->Isotope->Cart->shippingAddress['phone'],
             			'company'		=> $this->Isotope->Cart->shippingAddress['company'],
             			'street'		=> $this->Isotope->Cart->shippingAddress['street_1'],
             			'street2'		=> $this->Isotope->Cart->shippingAddress['street_2'],
             			'street3'		=> $this->Isotope->Cart->shippingAddress['street_3'],
             			'city'			=> $this->Isotope->Cart->shippingAddress['city'],
             			'state'			=> $this->Isotope->Cart->shippingAddress['subdivision'],
             			'zip'			=> $this->Isotope->Cart->shippingAddress['postal'],
             			'country'		=> $this->Isotope->Cart->shippingAddress['country']
             		);*/
             /*$arrOrigin = array
             		(
             			'name'			=> $this->Isotope->Config->firstname . ' ' . $this->Isotope->Config->lastname,
             			'phone'			=> $this->Isotope->Config->phone,
             			'company'		=> $this->Isotope->Config->company,
             			'street'		=> $this->Isotope->Config->street_1,
             			'street2'		=> $this->Isotope->Config->street_2,
             			'street3'		=> $this->Isotope->Config->street_3,
             			'city'			=> $this->Isotope->Config->city,
             			'state'			=> $this->Isotope->Config->state,
             			'zip'			=> $this->Isotope->Config->postal,
             			'country'		=> $this->Isotope->Config->country
             		);*/
             $arrCountries = $this->getCountries();
             $destCountryText = $arrCountries[$this->Isotope->Cart->shippingAddress['country']];
             $this->strOriginZip = $this->Isotope->Config->postal;
             $this->strDestinationZip = $this->Isotope->Cart->shippingAddress['postal'];
             $this->strDestinationCountry = $this->Isotope->Cart->shippingAddress['country'];
             $this->strDestinationCountryText = $this->Isotope->Cart->shippingAddress['country'] == 'uk' ? 'Great Britain' : $destCountryText;
             $this->strShippingMode = $this->getShippingMode($this->Isotope->Cart->shippingAddress['country']);
             $this->blnDomestic = $this->Isotope->Cart->shippingAddress['country'] != 'us' ? false : true;
             if (!$this->blnDomestic) {
                 $this->strAPIMode = 'IntlRate';
             }
             $fltWeight = $this->Isotope->Cart->getShippingWeight('lb');
             $arrWeight = explode('.', (string) $fltWeight);
             $this->arrWeightData = array('pounds' => $arrWeight[0], 'ounces' => (int) $arrWeight[1] / 100 * 16);
             return $this->calculateShippingRate();
             break;
     }
     return parent::__get($strKey);
 }
 /**
  * Return an object property
  *
  * @access public
  * @param string
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'price':
             $arrShipment = $this->Shipment;
             if (!count($this->Shipment) || ($arrShipment['address']['postal'] == $this->Isotope->Config->postal && $arrShipment['address']['subdivision'] == $this->Isotope->Config->subdivision && $arrShipment['address']['country'] == $this->Isotope->Config->country && (!isset($arrShipment['address']['firstname']) || !isset($arrShipment['address']['lastname']) || !isset($arrShipment['address']['city']) || !isset($arrShipment['address']['subdivision']) || !isset($arrShipment['address']['postal']) || !isset($arrShipment['address']['country']) || !isset($arrShipment['address']['street_1'])) || ($arrShipment['address']['firstname'] == '' || $arrShipment['address']['lastname'] == '' || $arrShipment['address']['city'] == '' || $arrShipment['address']['subdivision'] == '' || $arrShipment['address']['postal'] == '' || $arrShipment['address']['country'] == '' || $arrShipment['address']['street_1'] == ''))) {
                 return 0;
             }
             $blnShowError = false;
             $strPrice = $this->arrData['price'];
             $blnPercentage = substr($strPrice, -1) == '%' ? true : false;
             if ($blnPercentage) {
                 $fltSurcharge = (double) substr($strPrice, 0, -1);
                 $fltPrice = $this->Isotope->Cart->subTotal / 100 * $fltSurcharge;
             } else {
                 $fltPrice = (double) $strPrice;
             }
             $arrPackage = $this->buildShipment();
             list($arrOrigin, $arrDestination, $arrShipment) = $arrPackage;
             //Cache the request so we don't have to run it again as the API is slow
             $strRequestHash = md5(implode('.', $arrDestination) . $arrShipment['service'] . $arrShipment['weight'] . implode('.', $this->Shipment['productids']) . $this->Shipment['quantity']);
             if ($_SESSION['CHECKOUT_DATA']['UPS'][$strRequestHash]) {
                 $arrResponse = $_SESSION['CHECKOUT_DATA']['UPS'][$strRequestHash];
             } else {
                 // Construct UPS Object: For now, Origin is assumed to be the same for origin and shipping info
                 $objUPSAPI = new UpsAPIRatesAndService($arrShipment, $arrOrigin, $arrOrigin, $arrDestination);
                 $strRequestXML = $objUPSAPI->buildRequest('RatingServiceSelectionRequest');
                 $arrResponse = $objUPSAPI->sendRequest($strRequestXML);
                 $_SESSION['CHECKOUT_DATA']['UPS'][$strRequestHash] = $arrResponse;
                 if ($this->blnShowError) {
                     $blnShowError = true;
                 }
             }
             if ((int) $arrResponse['RatingServiceSelectionResponse']['Response']['ResponseStatusCode'] == 1) {
                 $fltUPSPrice = floatval($arrResponse['RatingServiceSelectionResponse']['RatedShipment']['TotalCharges']['MonetaryValue']);
             } elseif ($blnShowError) {
                 $strLogMessage = sprintf('Error in shipping digest: %s - %s', $arrResponse['RatingServiceSelectionResponse']["Response"]["ResponseStatusDescription"], $arrResponse['RatingServiceSelectionResponse']["Response"]["Error"]["ErrorDescription"]);
                 $strMessage = sprintf('%s - %s', $arrResponse['RatingServiceSelectionResponse']["Response"]["ResponseStatusDescription"], $arrResponse['RatingServiceSelectionResponse']["Response"]["Error"]["ErrorDescription"]);
                 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                     // add something if this is an ajax with error?
                 } else {
                     //Log and display error if this is not an AJAX request to prevent a billion error msgs
                     $_SESSION['ISO_ERROR']['ups'] = $strMessage;
                 }
                 $this->log($strLogMessage, __METHOD__, TL_ERROR);
             }
             return $this->Isotope->calculatePrice($fltPrice + $fltUPSPrice, $this, 'price', $this->arrData['tax_class']);
             break;
         case 'available':
             $blnAvailable = $this->price > 0 ? parent::__get('available') : false;
             // HOOK for determining availability
             if (isset($GLOBALS['ISO_HOOKS']['shippingAvailable']) && is_array($GLOBALS['ISO_HOOKS']['shippingAvailable'])) {
                 foreach ($GLOBALS['ISO_HOOKS']['shippingAvailable'] as $callback) {
                     $this->import($callback[0]);
                     $blnAvailable = $this->{$callback}[0]->{$callback}[1]($blnAvailable, $this);
                 }
             }
             return $blnAvailable;
             break;
     }
     return parent::__get($strKey);
 }