[Resolved] AwoCoupon plugin for AcyMailing Vieuw code in browser doesn't work


  • Default avatar
    jeroen    
     13 years ago
    0

    AwoCoupon plugin for AcyMailing Ad the top of the acymail news-letter is a link to Vieuw the e-mail in your browser
    the coupon code doesn't work in the webpage the only thing you get to see
    {awocoupon:[name][key]|33|6|1} Not the actual key. also when you are logged in.
    Does any one know if this is normal?
    Is that suposed not to work or do i have a error?
  • Your avatar
    seyi    
     13 years ago
    0

    i think you should send a test newsletter to yourself. this is when the actual coupon code is generated and you should then see it in the newsletter you receive.
  • Default avatar
    jeroen    
     13 years ago
    0

    Hello Seyi,
    In the e-mail the coupon code is displayed correctly.
    But in the e-mail there is a link you can click if you don't see the graphics.
    These are the tags for the online version link. {readonline}klick me to display in your browser{/readonline}.
    This link sends you to a page on my website where the news letter e-mail content is displayed.
    Everything works in this online version of the newsletter e-mail but only not the coupon code it does not
    get processed even when the person is logged in.
  • Your avatar
    seyi    
     13 years ago
    0

    You are right, this is not taken care of. This is a general archive of newsletters. Also there is no database keeping track of what coupon was emailed to what user for what newsletter, so it is not really possible to enter the actual coupon code in this area. But the text can be changed to something more friendly.

    This will be updated for the next release, but for now, this is what you can do.

    in www/plugins/acymailing/awocoupon.php, add this function into the class

    <?php
    function acymailing_replaceusertagspreview(&$email,&$user){
        
    $match '#{awocoupon:(.*)}#Ui';
        
    $variables = array('subject','body','altbody');
        
    $found false;
        foreach(
    $variables as $var){
            if(empty(
    $email->$var)) continue;
            
    $found preg_match_all($match,$email->$var,$results[$var]) || $found;
            if(empty(
    $results[$var][0])) unset($results[$var]);
        }
        if(!
    $found) return;
        
        
    $tags = array();
        foreach(
    $results as $var => $allresults){
            foreach(
    $allresults[0] as $i => $oneTag){
                if(isset(
    $tags[$oneTag])) continue;
                
    $tags[$oneTag] = '{personal coupon code}';
            }
        }
        foreach(
    array_keys($results) as $var){
            
    $email->$var str_replace(array_keys($tags),$tags,$email->$var);
        }
    }
    ?>


    This will replace the tag with {personal coupon code}
  • Default avatar
    jeroen    
     13 years ago
    0

    Thanks Seyi,
    I will try this solution.
    Will let you know if it works just fine.

    Greetings,
    Jeroen.

    Yes it Works Fine Thanks!
    I put your code on line 24 of the awocoupon.php file.
    Like this:

    <?php
    function plgAcymailingAwoCoupon(&$subject$config){
            
    // load language file
            
    $language =& JFactory::getLanguage();
            
    $language->load('com_awocoupon');

            
    parent::__construct($subject$config);
            if(!isset(
    $this->params)){
                
    $plugin =& JPluginHelper::getPlugin('acymailing''awocoupon');
                
    $this->params = new JParameter$plugin->params );
            }
        }

    function 
    acymailing_replaceusertagspreview(&$email,&$user){
        
    $match '#{awocoupon:(.*)}#Ui';
        
    $variables = array('subject','body','altbody');
        
    $found false;
        foreach(
    $variables as $var){
            if(empty(
    $email->$var)) continue;
            
    $found preg_match_all($match,$email->$var,$results[$var]) || $found;
            if(empty(
    $results[$var][0])) unset($results[$var]);
        }
        if(!
    $found) return;
        
        
    $tags = array();
        foreach(
    $results as $var => $allresults){
            foreach(
    $allresults[0] as $i => $oneTag){
                if(isset(
    $tags[$oneTag])) continue;
                
    $tags[$oneTag] = '{personal coupon code}';
            }
        }
        foreach(
    array_keys($results) as $var){
            
    $email->$var str_replace(array_keys($tags),$tags,$email->$var);
        }
    }
         function 
    acymailing_getPluginType() {

             
    $onePlugin null;
             
    $onePlugin->name 'AwoCoupon';
             
    $onePlugin->function 'acymailingawocoupon_show';
             
    $onePlugin->help 'plugin-awocoupon';

             return 
    $onePlugin;
         }
    ?>


    Thanks Seyi,
    You solved this!

    By the way did you just now write this code?

    Greetzz,
    Jeroen