Prevent a client assigned to an Affiliate, you can use the coupon assignment to another affiliate


  • Default avatar
    candido    
     9 years ago
    0

    Hello.

    We are linking buyers with to our affiliates using coupons single use per customer.

    These coupons, in addition to the function of the affiliate entailment, also provide a discount to the buyer.

    We have a problem: when a customer uses a coupon is linked perfectly affiliate and the affiliate receives commissions that buyer, always. But the buyer can use the coupon for another affiliate to regain a new discount, but not be linked to that affiliate.
    How can we avoid it automatically, a buyer can use more than one coupon affiliate, to prevent receive a new discount?

    thanks
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    Are you saying that a customer is using 2 different affiliate coupon codes in one shopping cart? The only way to stop this currently is to disable accepting of multiple coupon codes.

    Or you could modify awocoupon to check for it. Here is what you can do,
    in www/administrator/components/com_awocoupon/helpers/estore/estorecouponhandler.php, around line 216 is this
    <?php
            $coupon_awo_entered_coupon_ids 
    $iscaseSensitive array_unique($coupon_awo_entered_coupon_ids) : $this->array_iunique($coupon_awo_entered_coupon_ids);
    ?>


    After that add this
    <?php
            
    # AWOAFFILIATE ONE COUPON CODE MAX CHECK
                
    $sql 'SELECT c.coupon_code
                          FROm #__awoaffiliate a
                          JOIN #__awocoupon c ON c.id=a.coupon_id
                          WHERE c.coupon_code IN ("'
    .implode('","',$coupon_awo_entered_coupon_ids).'")
                          ORDER BY FIELD(c.coupon_code, "'
    .implode('","',$coupon_awo_entered_coupon_ids).'")';
                
    $db->setQuery$sql );
                
    $affiliate_codes $db->loadObjectList();
                if(
    count($affiliate_codes)>1) {
                    
    array_shift($affiliate_codes);
                    foreach(
    $affiliate_codes as $c) {
                        if((
    $key array_search($c$coupon_awo_entered_coupon_ids)) !== false) unset($coupon_awo_entered_coupon_ids[$key]);
                    }
                }
            }
    ?>

  • Default avatar
    candido    
     9 years ago  last edited 7 years ago
    0

    Yes. What we want is that a buyer can not use two coupons of different affiliates in the same shopping cart, or different.

    We want the buyer has used a coupon affiliate, you can not use more coupons other affiliates.


    I tried to apply your solution in the code, but in line 216 there is nothing like what you're saying.

    That line exists and is repeated twice in lines 431 and 455. Which one of them should I place the code?

    This is an excerpt of what I find:


    <?php
    </p><p>            if(!$this->giftcert_inuse($submitted_coupon_code)) $coupon_awo_entered_coupon_ids[] = awolibrary::dbEscape($submitted_coupon_code);
            }
            $coupon_awo_entered_coupon_ids $iscaseSensitive array_unique($coupon_awo_entered_coupon_ids) : $this->array_iunique($coupon_awo_entered_coupon_ids);

            $this->initialize_coupon();
            //JFactory::getApplication()->set('_messageQueue','');
            
            $auto_codes 
    = @$this->get_coupon_auto()->coupons;
            if(empty($coupon_awo_entered_coupon_ids) && empty($auto_codes)) return $this->return_false('errNoRecord');
            if(empty($auto_codes)) $auto_codes = array();
            foreach($auto_codes as $auto_code) {
                $multiple_coupons['auto'][] = $auto_code->coupon_code;
                $coupon_awo_entered_coupon_ids[] = awolibrary::dbEscape($auto_code->coupon_code);
            }
            $coupon_awo_entered_coupon_ids $iscaseSensitive array_unique($coupon_awo_entered_coupon_ids) : $this->array_iunique($coupon_awo_entered_coupon_ids);
        
    ?>

  • Your avatar
    seyi    
     9 years ago
    0

    Place it after the first, so after line 431.
  • Default avatar
    candido    
     9 years ago
    0

    I checked. It does not work.
    I still use other coupons affiliate, although I'm already assigned to an affiliate, and I am logged in, I mean that the system knows, theoretically, I am referring.
    I send the complete code in private message so you can check if I have corrected well
  • Default avatar
    candido    
     9 years ago
    0

    Hi Seyi .

    The above solution does not work and I have found other problems.

    Trying to solve this problem I have found that there are other faults.
    I'll explain a little better what you are trying to do :

    We link customers to affiliate marketers . We use coupons affiliate. It is a coupon father with three children coupons . Each coupon son is activated if a condition is satisfied purchase .

    Problems or configuration errors:

    The coupon father does not bind the buyer to the affiliate. The entailment occurs with coupons son . This means that each member have to do three coupons, but with this setup can work.

    The coupon father is single use per customer. It does not work . You can use it whenever you want.

    When you use the coupon father, and continued buying, coupon benefits each child if they are fulfilling their particular conditions are added .
    As can be configured to only benefit one's and once applied ? We have tried different settings and we do not.

    A buyer who has used a coupon affiliate, and therefore , is linked to the seller and may be used in the same purchase or otherwise the other affiliate coupon to take advantage of discounts. This is a very serious problem .

    As we proceed to use the coupon only possible when the buyer is logged in? I think to solve the above this part is important because the system must recognize the buyer. Or maybe you can fix it otherwise. The problem is that if you use the coupon before you log in, to shopping discounts apply, but if you are not because you're a buyer, but after you identify and the system recognizes you, discounts no longer disappear if basket have no right to them. This is one of the problems associated with the possibility of using different affiliate coupons, but whether you're a buyer referral.

    I hope you can help me. Thank you.
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    I am sorry but I am really not following all the problems. Maybe we can try it one at a time. First question, what version of AwoCoupon are you using?

    The only problem I understand is the number of uses per customer not working for parent coupons with process type highest value, lowest value, and first found match. This bug can be solved by editing
    www/administrator/components/com_awocoupon/helpers/estore/estorecouponhandler.php, search for
    <?php
            
    'coupon_entered_id'=>$r[1]['coupon_id'],
    ?>


    And change it to
    <?php
            
    'coupon_entered_id'=>!empty($r[1]['coupon_entered_id']) ? $r[1]['coupon_entered_id'] : $r[1]['coupon_id'],
    ?>
  • Default avatar
    candido    
     9 years ago
    0

    Ok. I guess my English is not very good. Sorry.

    Let each of them:

    The problem of parent coupons for the same customer can use it only once, this solved. The problem is that it is only effective when the buyer is logged.

    If the buyer is not logged in, you can enter the coupon, get the benefit, and then log in. As the benefit of the coupon is already in the basket, the system is not removed. So the buyer can cheat.


    The version I use is:

    Awocoupon Pro 2.2.7
    Virtuemart 2.0.26
    Joomla 2.5.19

  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    That is not true. As soon as you log in, the coupon is rechecked and if the customer email address has used the coupon too many times it is removed.

    Please keep in mind that the code I gave you does not affect old orders, only new ones. You can tell which orders it affects by going to awocoupon->history->coupons and under the coupon code field if you see:

    parent_code ( child_code )

    Then this is counted towards the parent coupon number of uses. If under coupon code you just see:

    child_code

    Then it is not counted towards the parent coupon number of uses.
  • Default avatar
    candido    
     9 years ago
    0

    Well do not get it.

    I have made a purchase using a coupon parent. This activates another type coupon Buy X Get Y. Finish the purchase and close the session.

    Repeat purchase without login. I apply the coupon. And now I get logging. indeed, the code of the coupon disappears because the system recognizes me, but the product Y, continues to be in the basket!
  • Default avatar
    candido    
     9 years ago
    0

    Sorry, you're right.
    I came back to check, and although the product "Y" is in the cart, the price is not discounted.
    Well, this problem is solved.

    Now we have to solve the more complex problem:

    A customer who already used a coupon affiliate, can also use other coupons affiliates. The commission is for the first, but the customer can take advantage of discounts of other coupons. How can we avoid this? We just want every buyer can use only one coupon affiliate.
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    in AwoCoupon 2.2.7, the code I gave you previously is commented out, so you can just uncomment it. This will stop 2 or more different affiliate coupons from being used in the same shopping cart. This assumes, if you are using parent coupons, that the parent coupons are the affiliate coupons and not the children.
  • Default avatar
    candido    
     9 years ago
    0

    Hello,

    I'm using coupons parent, but the affiliate coupon is the children, not the parent. This is because in previous tests, I can see that the coupon parent not fulfilling the function of Affiliate.
    Doing so would be perfect, but I have not worked previously.
    Do not know if it works now, with the new version of AWO....
  • Default avatar
    candido    
     9 years ago
    0

    No. It does not work.
    I have uncommented the part of code that you tell me.
    I made a new test, using the coupon father, and also his sons, as coupons affiliate, all, and although I am linked to an affiliate, I can still use coupons from other affiliates.
  • Default avatar
    candido    
     9 years ago
    0

    What we need is to prevent different affiliate coupons used in one basket or in different baskets if you've ever used one before.
  • Your avatar
    seyi    
     9 years ago
    0

    After the above fix for the number of uses in parent coupons, yes, affilaite parents should work. You should remove affiliate coupons as children coupons because I do not think commissions will be calculated any more on children coupon if a customer puts in the parent coupon.
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    Change it to this
    <?php
            
    # AWOAFFILIATE ONE COUPON CODE MAX CHECK
                
    $user JFactory::getUser();

                
    $sql 'SELECT c.coupon_code,r.id as rid
                          FROm #__awoaffiliate a
                          JOIN #__awocoupon c ON c.id=a.coupon_id
                          LEFT JOIN #__awoaffiliate_referral r ON r.referral_user_id = '
    .(int)$user->id.'
                          WHERE c.coupon_code IN ("'
    .implode('","',$coupon_awo_entered_coupon_ids).'")
                          GROUP BY c.id
                          ORDER BY FIELD(c.coupon_code, "'
    .implode('","',$coupon_awo_entered_coupon_ids).'")
                         '
    ;
                
    $db->setQuery$sql );
                
    $affiliate_codes $db->loadObjectList();
                if(!empty(
    $affiliate_codes)) {
                    
    $only_one_aff_code array_shift($affiliate_codes);
                    if(
    count($affiliate_codes)>1) {
                        foreach(
    $affiliate_codes as $c) {
                            if((
    $key array_search($c->coupon_code$coupon_awo_entered_coupon_ids)) !== false) unset($coupon_awo_entered_coupon_ids[$key]);
                        }
                    }
                    { 
    # AWOAFFILIATE ALL AFFILIATE COUPONS IF ALREADY A REFERRAL
                        
    if(!empty($only_one_aff_code->rid)) {
                            if((
    $key array_search($only_one_aff_code->coupon_code$coupon_awo_entered_coupon_ids)) !== false) unset($coupon_awo_entered_coupon_ids[$key]);
                        }
                    }
                }
            }
    ?>


    This assumes the couon entered by the customer is the affiliate coupon and also customers who have used a coupon in the past are referrals and show on the awoaffiliate->referral screen.
  • Default avatar
    candido    
     9 years ago
    0

    Ok. Now works perfectly as we needed.

    Thank you very much for your help.