/** * recognizes commission type for campaign * * @param Pap_Plugins_Tracking_Action_Context $context */ public function getCommissionType(Pap_Contexts_Action $context) { $campaign = $context->getCampaignObject(); $context->debug('Recognizing commission type started'); $actionCode = $context->getActionCodeFromRequest(); if ($actionCode == null || $actionCode == '') { $type = Pap_Common_Constants::TYPE_SALE; } else { $type = Pap_Common_Constants::TYPE_ACTION; } try { $context->debug(' Checking commission type : '.$type.' is in campaign'); $commissionType = $campaign->getCommissionTypeObject($type, $context->getActionCodeFromRequest(), $context->getVisit()->getCountryCode()); } catch (Pap_Tracking_Exception $e) { $context->debug(" STOPPING, This commission type is not supported by current campaign or is NOT enabled! "); throw $e; } $context->setCommissionTypeObject($commissionType); $context->getTransaction(1)->setType($type); $context->debug(' Commission type set to: '.$type.', ID: '.$commissionType->getId()); $context->debug('Recognizing commission type ended'); $context->debug(""); }
public function getCommissionType(Pap_Contexts_Action $context) { $context->debug("Begin recognizing country specific commission type"); if(!strlen($context->getTransactionObject()->getCountryCode())) { $context->debug("STOPPING recognizing country specific commission type eneded: country code not recognized or empty"); return; } $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_CommissionTypes::getInstance()); $select->from->add(Pap_Db_Table_CommissionTypes::getName()); $select->where->add(Pap_Db_Table_CommissionTypes::PARENT_COMMISSIONTYPE_ID, '=', $context->getCommissionTypeObject()->getId()); $compoundContext = new Gpf_Data_Record(array(Pap_Db_Table_RawImpressions::IP, Pap_Db_Table_Impressions::COUNTRYCODE), array($context->getVisit()->getIp(), '')); $this->getCountryCode($compoundContext); $countryCode = $compoundContext->get(Pap_Db_Table_Impressions::COUNTRYCODE); if (!strlen($countryCode)) { $context->debug("STOPPING recognizing country specific commission type eneded: country code not recognized or empty"); return; } $select->where->add(Pap_Db_Table_CommissionTypes::COUNTRYCODES, 'LIKE', '%'.$countryCode.'%'); try { $commType = new Pap_Db_CommissionType(); $collection = $commType->loadCollectionFromRecordset($select->getAllRows()); $context->setCommissionTypeObject($collection->get(0)); } catch (Gpf_DbEngine_NoRowException $e) { $context->debug("Recognizing country specific commission type eneded - no country secpific commission defined"); return; } catch (Gpf_DbEngine_TooManyRowsException $e) { $context->debug("STOPPING ecognizing country specific commission type eneded: more than one commision type is defined for country " . $context->getTransactionObject()->getCountryCode()); return; } catch (Gpf_Exception $e) { $context->debug("STOPPING recognizing country specific commission type eneded: " . $e->getMessage()); } }
/** * @param Pap_Contexts_Action $context * @return Pap_Db_CommissionType */ protected function getCommissionType(Pap_Contexts_Action $context) { $campaign = $context->getCampaignObject(); $actionCode = $context->getActionCodeFromRequest(); if ($actionCode != '') { return $campaign->getCommissionTypeObject(Pap_Common_Constants::TYPE_ACTION, $actionCode, $context->getVisit()->getCountryCode()); } else { return $campaign->getCommissionTypeObject(Pap_Common_Constants::TYPE_SALE, '', $context->getVisit()->getCountryCode()); } }