Beispiel #1
0
 /**
  * Return a value
  * @param string
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'order_id':
             return $this->strOrderId;
         case 'billingAddress':
             return deserialize($this->arrData['billing_address'], true);
         case 'shippingAddress':
             return deserialize($this->arrData['shipping_address'], true);
         case 'paid':
             return (int) $this->date_paid >= time() && $this->status == 'complete';
         default:
             return parent::__get($strKey);
     }
 }
Beispiel #2
0
 /**
  * Return the cart data
  * @param string
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'billing_address':
         case 'billingAddress':
             if ($this->arrSettings['billingAddress_id'] > 0) {
                 $objAddress = $this->Database->prepare("SELECT * FROM tl_iso_addresses WHERE id=?")->limit(1)->execute($this->arrSettings['billingAddress_id']);
                 if ($objAddress->numRows) {
                     return $objAddress->fetchAssoc();
                 }
             } elseif ($this->arrSettings['billingAddress_id'] === 0 && is_array($this->arrSettings['billingAddress_data'])) {
                 return $this->arrSettings['billingAddress_data'];
             }
             $this->import('Isotope');
             if (FE_USER_LOGGED_IN === true) {
                 $objAddress = $this->Database->prepare("SELECT * FROM tl_iso_addresses WHERE pid={$this->User->id} AND store_id={$this->Isotope->Config->store_id} AND isDefaultBilling='1'")->limit(1)->execute();
                 if ($objAddress->numRows) {
                     return $objAddress->fetchAssoc();
                 }
                 // Return the default user data, but ID should be 0 to know that it is a custom/new address
                 // Trying to guess subdivision by country and state
                 return array_intersect_key(array_merge($this->User->getData(), array('id' => 0, 'street_1' => $this->User->street, 'subdivision' => strtoupper($this->User->country . '-' . $this->User->state))), array_flip($this->Isotope->Config->billing_fields_raw));
             }
             return array('id' => -1, 'postal' => $this->Isotope->Config->postal, 'subdivision' => $this->Isotope->Config->subdivision, 'country' => $this->Isotope->Config->country);
         case 'shipping_address':
         case 'shippingAddress':
             if ($this->arrSettings['shippingAddress_id'] == -1) {
                 return array_merge($this->billingAddress, array('id' => -1));
             }
             if ($this->arrSettings['shippingAddress_id'] > 0) {
                 $objAddress = $this->Database->prepare("SELECT * FROM tl_iso_addresses WHERE id=?")->limit(1)->execute($this->arrSettings['shippingAddress_id']);
                 if ($objAddress->numRows) {
                     return $objAddress->fetchAssoc();
                 }
             }
             if ($this->arrSettings['shippingAddress_id'] == 0 && count($this->arrSettings['shippingAddress_data'])) {
                 return $this->arrSettings['shippingAddress_data'];
             }
             if (FE_USER_LOGGED_IN === true) {
                 $this->import('Isotope');
                 $objAddress = $this->Database->prepare("SELECT * FROM tl_iso_addresses WHERE pid={$this->User->id} AND store_id={$this->Isotope->Config->store_id} AND isDefaultShipping='1'")->limit(1)->execute();
                 if ($objAddress->numRows) {
                     return $objAddress->fetchAssoc();
                 }
             }
             return array_merge(is_array($this->billingAddress) ? $this->billingAddress : array(), array('id' => -1));
         default:
             return parent::__get($strKey);
     }
 }