public function addCommission(Pap_Contexts_Signup $signupContext) { if (($user = $signupContext->getUserObject()) == null) { return; } $campaignId = Gpf_Settings::get(SignupActionCommissions_Config::AFTER_SIGNUP_ACTION_CAMPAIGNID); $actionCode = Gpf_Settings::get(SignupActionCommissions_Config::AFTER_SIGNUP_ACTION_CODE); if ($actionCode == '') { Gpf_Log::error('SignupActionCommissions plugin: No Action code set'); return; } $saleTracker = new Pap_Tracking_ActionTracker(); $action = $saleTracker->createAction($actionCode); $action->setAffiliateID($user->getId()); $action->setStatus($user->getStatus()); $action->setOrderId(SignupActionCommissions_Config::DEFAULT_ORDER_ID); if ($campaignId != '') { $action->setCampaignID($campaignId); } try { $saleTracker->register(); } catch (Gpf_Exception $e) { Gpf_Log::error('SignupActionCommissions plugin: '.$e->getMessage()); } }
private function processWholeCartAsOneTransaction() { $this->debug("Whole cart as one transaction..."); $saleTracker = new Pap_Tracking_ActionTracker(); $sale = $saleTracker->createSale(); $sale->setOrderId($this->getOrderID()."_".$this->getData1()); $sale->setTotalCost($this->getTotalCost()); $sale->setProductId($this->getProductID()); $sale->setAffiliateID($this->getAffiliateID()); $cookie = $this->parseCookie(stripslashes($this->getCookie())); $this->setVisitorAndAccount($saleTracker, $this->getAffiliateID(), $this->getCampaignID(), $cookie); $this->registerAllSales($saleTracker); }
private function processWholeCartAsOneTransaction() { $this->debug('PremiumWebCart - Process whole cart as one transaction'); $order = $this->xml->order[0]; $product = $order->products[0]->product[0]; $saleTracker = new Pap_Tracking_ActionTracker(); $sale = $saleTracker->createSale(); $totalCost = 0; $productId = ''; foreach ($order->products[0] as $item) { $totalCost += $item->totalprice; $productId .= (string)$item->name . ', '; } $sale->setOrderId((string)$order->orderuniqueid); $sale->setTotalCost($totalCost); $sale->setProductId(substr($productId, 0, -2)); $this->registerAllSales($saleTracker); }
protected function registerCommission() { $this->debug("Start registering sale, params PAP_COOKIE='".$this->getCookie()."', TotalCost='".$this->getTotalCost()."', OrderID='".$this->getOrderID()."', ProductID='".$this->getProductID()."'"); $saleTracker = Pap_Tracking_ActionTracker::getInstance(); $sale = $saleTracker->createSale(); $sale->setTotalCost($this->getTotalCost()); $sale->setOrderID($this->getOrderID()); $sale->setProductID($this->getProductID()); $saleTracker->setVisitorId($this->getCookie()); $saleTracker->setAccountId(Gpf_Db_Account::DEFAULT_ACCOUNT_ID); $saleTracker->register(); $this->debug("End registering sale"); }
private function createSale(Gpf_Rpc_Form $form) { $saleTracker = new Pap_Tracking_ActionTracker(); $sale = $saleTracker->createSale(); $sale->setTotalCost($form->getFieldValue(Pap_Db_Table_Transactions::TOTAL_COST)); $sale->setOrderID($form->getFieldValue(Pap_Db_Table_Transactions::ORDER_ID)); $sale->setProductID($form->getFieldValue(Pap_Db_Table_Transactions::PRODUCT_ID)); $sale->setData1($form->getFieldValue(Pap_Db_Table_Transactions::DATA1)); $sale->setData2($form->getFieldValue(Pap_Db_Table_Transactions::DATA2)); $sale->setData3($form->getFieldValue(Pap_Db_Table_Transactions::DATA3)); $sale->setData4($form->getFieldValue(Pap_Db_Table_Transactions::DATA4)); $sale->setData5($form->getFieldValue(Pap_Db_Table_Transactions::DATA5)); $sale->setCoupon($form->getFieldValue(Pap_Db_Table_Coupons::CODE)); Gpf_Plugins_Engine::extensionPoint('PostAffiliate.OfflineSaleForm.createSale', $sale); // For handle Affiliate Sale Tracking Codes, this feature write its codes to output ob_start(); $saleTracker->register(); ob_end_clean(); $form->setInfoMessage($this->_('Sale was saved')); }
private function prepareSeparateCartItems(Pap_Tracking_ActionTracker $saleTracker) { $request = $this->getRequestObject(); $numItems = $request->getPostParam('num_cart_items'); for ($i=1; $i<=$numItems; $i++) { $sale = $saleTracker->createSale(); $sale->setTotalCost($this->adjustTotalCost($request->getPostParam('mc_gross_'.$i), $request, $i)); $sale->setOrderID($this->getOrderID()); $sale->setProductID($request->getPostParam('item_number'.$i)); $sale->setData1($this->getData1()); $sale->setData2($this->getData2()); $sale->setData3($this->getData3()); $sale->setData4($this->getData4()); $sale->setData5($this->getData5()); $sale->setCoupon($this->getCouponCode()); $sale->setCurrency($this->getCurrency()); $sale->setChannelId($this->getChannelId()); if ($this->getStatus()!='') { $sale->setStatus($this->getStatus()); } if($this->getAffiliateID() != '' && $this->getCampaignID() != '') { $sale->setAffiliateID($this->getAffiliateID()); $sale->setCampaignID($this->getCampaignID()); } $this->setVisitorAndAccount($saleTracker, $this->getAffiliateID(), $this->getCampaignID(), $this->getCookie()); } }
private function prepareSeparateCartItems(Pap_Tracking_ActionTracker $saleTracker) { $this->debug('Per item registration started...'); $request = $this->getRequestObject(); $Items = explode("|",$this->doubleColonProducts); for ($i=0; $i<count($Items)-1; $i++) { $item = explode("::",$Items[$i]); // Price::Qty::Code::Description::Flags:: $sale = $saleTracker->createSale(); $sale->setTotalCost($item[0]*$item[1]); $sale->setOrderID($this->getOrderID()."_".$i); $sale->setProductID($item[2]); $sale->setData1($this->getData1()); $sale->setData2($this->getData2()); $sale->setData3($this->getData3()); $sale->setData4($this->getData4()); $sale->setData5($this->getData5()); $sale->setCurrency($this->getCurrency()); $sale->setChannelId($this->getChannelId()); if ($this->getStatus()!='') { $sale->setStatus($this->getStatus()); } if ($this->getAffiliateID() != '' && $this->getCampaignID() != '') { $sale->setAffiliateID($this->getAffiliateID()); $sale->setCampaignID($this->getCampaignID()); } $this->setVisitorAndAccount($saleTracker, $this->getAffiliateID(), $this->getCampaignID(), $this->getCookie()); } }
private function processWholeCartAsOneTransaction() { $saleTracker = new Pap_Tracking_ActionTracker(); $sale = $saleTracker->createSale(); $totalCost = 0; $productId = ''; $data2 = ''; foreach ($this->getCartItems() as $item) { $totalCost += (float)$this->getXmlElementByName('unit-price',$item)*(int)$this->getXmlElementByName('quantity',$item); $productId .= (string)$this->getXmlElementByName(Gpf_Settings::get(GoogleCheckout_Config::PRODUCT_ID_BY),$item) . ', '; if (Gpf_Settings::get(GoogleCheckout_Config::PRODUCT_ID_BY) != 'item-name') { $data2 .= (string)$this->getXmlElementByName('item-name',$item) . ', '; } } $sale->setOrderId($this->getOrderID()); $sale->setTotalCost($totalCost-$this->getCouponAmount()); $sale->setProductId(substr($productId, 0, -2)); if (Gpf_Settings::get(GoogleCheckout_Config::PRODUCT_ID_BY) != 'item-name') { $sale->setData2(substr($data2, 0, -2)); } $cookie = $this->parseCookie(stripslashes($this->getMerchantPrivateData())); $this->setVisitorAndAccount($saleTracker, $this->getAffiliateID(), $this->getCampaignID(), $cookie); $this->registerAllSales($saleTracker); }
protected function registerAllSales(Pap_Tracking_ActionTracker $saleTracker) { $this->debug('Registering all sales...'); $saleTracker->register(); $this->debug('All sales registered...'); }
/** * @return Pap_Tracking_ActionTracker */ public static function getInstance() { if (self::$instance == NULL) { self::$instance = new Pap_Tracking_ActionTracker(); } return self::$instance; }
<?php /** * Register sale/lead/action * * Sale tracking is made completely using plugins, every action is performed by a plugin */ require_once 'bootstrap.php'; Gpf_Session::create(new Pap_Merchant(), null, false); $request = new Pap_Tracking_ActionRequest(); $tracker = Pap_Tracking_ActionTracker::getInstance(); $tracker->setAccountId($request->getAccountId()); $tracker->setRefererUrl($request->getRefererUrl()); $tracker->setVisitorId($request->getVisitorId()); $tracker->setTrackMethod(Pap_Common_Transaction::TRACKING_METHOD_3RDPARTY_COOKIE); $action = $tracker->createAction($request->getRawActionCode()); $action->setTotalCost($request->getRawTotalCost()); $action->setOrderId($request->getRawOrderId()); $action->setProductId($request->getRawProductId()); for ($i=1; $i<=5; $i++) { $action->setData($i, $request->getRawExtraData($i)); } $action->setAffiliateId($request->getRawAffiliateId()); $action->setCampaignId($request->getRawCampaignId()); $action->setCustomCommission($request->getRawCustomCommission()); $action->setStatus($request->getRawCustomStatus()); $action->setCouponCode($request->getRawCoupon()); $action->setChannelId($request->getChannelId());