Beispiel #1
0
 public function getOrderDetails()
 {
     $shippingAddress = new FullAddress();
     $shippingAddress->fillFromDbPk($this->address_id);
     $billingAddress = new FullAddress();
     $billingAddress->fillFromDbPk($this->billing_address_id);
     $customer = new Customer();
     $customer->fillFromDbPk($this->customer_id);
     $click = new Click();
     $click->fillFromDbPk($this->click_id);
     $click->allFIelds = true;
     $click->loadConnections();
     $date = new DateTime();
     // DateTime($this->created);
     return array('orderId' => $this->order_id, 'billFirst' => $billingAddress->fname, 'billLast' => $billingAddress->lname, 'billAddress1' => $billingAddress->address1, 'billAddress2' => $billingAddress->address2, 'billCity' => $billingAddress->city, 'billState' => $billingAddress->state_name, 'billZip' => $billingAddress->zip, 'billCountry' => $billingAddress->country_name, 'billPhone' => $billingAddress->phone, 'billEmail' => $customer->email, 'shipFirst' => $shippingAddress->fname, 'shipLast' => $shippingAddress->lname, 'shipAddress1' => $shippingAddress->address1, 'shipAddress2' => $shippingAddress->address2, 'shipCity' => $shippingAddress->city, 'shipState' => $shippingAddress->state_name, 'shipZip' => $shippingAddress->zip, 'shipCountry' => $shippingAddress->country_name, 'shipPhone' => $shippingAddress->phone, 'shipEmail' => $customer->email, 'orderTotal' => sprintf("%.2f", $this->amount_product + $this->amount_shipping), 'dateOfSale' => $date->format('Y-m-d'), 'timeOfSale' => $date->format('H:i:s'), 'ipAddress' => $this->getip_formatted(), 'aff_id' => $click->aff_id === NULL ? '' : $click->aff_id, 'AFID' => $click->aff_ref === NULL ? $click->AFID : $click->aff_ref, 'SID' => $click->SID === NULL ? '' : $click->SID, 'c1' => $click->c1 === NULL ? '' : $click->c1, 'c2' => $click->c2 === NULL ? '' : $click->c2, 'c3' => $click->c3 === NULL ? '' : $click->c3, 'click_id' => $click->click_id, 'hit_id' => $click->hit_id);
 }
Beispiel #2
0
 private function buildClick($cid = null)
 {
     $this->click = new Click();
     // if a click id is already present, check the details against the post
     if ($cid && $this->click->fillFromDbPk($cid)) {
         if (isset($this->post['hit_id']) && $this->click->hit_id != $this->post['hit_id']) {
             $this->click = new Click();
         }
     }
     // is there a click id?
     if (!empty($this->post['click_id']) && is_numeric($this->post['click_id'])) {
         // is there a click record?
         if ($this->click->fillFromDbPk($this->post['click_id'])) {
             // check to see if click camp details match
             if ($this->campaign->campaign_id != $this->click->campaign_id) {
                 // reset click and continue
                 $this->click = new Click();
                 $this->post['hit_id'] = $this->post['click_id'];
                 $this->post['click_id'] = '';
                 //$this->apiError('error5 - Invalid campaign/click info');
             }
         } else {
             // there's a click_id, but it does not belong to LJ3.  disregard info
             $this->post['hit_id'] = $this->post['click_id'];
             $this->post['click_id'] = '';
         }
     }
     // is click empty?
     if (!$this->click->getPkValue()) {
         $this->click->fillFromArray($this->post);
         $this->click->fillIpAddress($this->post['user_ip']);
         $this->click->created = $this->click->updated = 'NOW():sql';
         //date("Y-m-d H:i:s");
         // check validity of
         // HOW TO HANDLE 3rd Party AFIDs?  is the afid called something different
         if (isset($this->post['AFID']) && strlen($this->post['AFID']) && !isset($this->post['aff_id'])) {
             $this->click->getAffId($this->post['AFID']);
             // did it work?  remove AFID then
             if ($this->click->aff_id) {
                 $this->click->AFID = '';
             }
         }
         $cookie_name = 's' . $this->click->campaign_id;
         $expire = time() + 3600 * 24 * 100;
         if (isset($this->cookie[$cookie_name])) {
             $old_click_id = $this->cookie[$cookie_name];
             // check the ID
             $c = new Click();
             $c->fillFromDbPk($old_click_id);
             if ($c->getPkValue()) {
                 // is this click from a different affiliate?  if so, don't use the old cookie click
                 if ($c->aff_id == $this->click->aff_id) {
                     $this->click->fillFromDbPk($old_click_id);
                     unset($c);
                     setcookie($cookie_name, $old_click_id, $expire, "/");
                     return;
                 }
                 unset($c);
             }
         }
         if (!$this->click->save()) {
             $this->apiError('click error ' . $this->click->geterrors2string());
         }
         setcookie($cookie_name, $this->click->click_id, $expire, "/");
     }
 }