PHP code example of shaygan / affiliate-bundle
1. Go to this page and download the library: Download shaygan/affiliate-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shaygan / affiliate-bundle example snippets
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
// register the bundle here
new \Shaygan\AffiliateBundle\ShayganAffiliateBundle()
);
}
}
// ...
// MyOrder SHOULD implements \Shaygan\AffiliateBundle\Model\OrderInterface
$order = new \AppBundle\Entity\MyOrder();
$order->setOwnerUser($this->getUser());
$em = $this->getDoctrine()->getManager();
$em->persist($order);
$em->flush();
$affiliate = $this->get("shaygan_affiliate");
$commission = $affiliate->getPurchaseCommission($order);
if(null !== $commission){
$commissionAmount = $commission->getCommissionAmount();
$referrer = $commission->getReferrer();
$referrerUserId = $referrer->getId();
// You can apply the commission amount to the accont of referrer User here
// ...
}
//...