List Coupon Codes always blank


  • Default avatar
    curra9    
     4 years ago
    0

    Hi,

    I have several coupons for different situations but when I create a menu with List Coupon Codes it is always blank. Is this only for when the coupon in personalize to one client or this works with, for example, shopper groups, etc...?

    Thank you.
  • Your avatar
    seyi    
     4 years ago
    0

    Hello, the coupon list menu item shows the coupon codes for the current logged in user. The codes have to be assigned to the user otherwise it will not show up.
  • Default avatar
    curra9    
     4 years ago
    0

    So it has to be only for that client? if the client is inside a shopper group a that shopper group has a coupon it won't appear, no?

    :(
  • Your avatar
    seyi    
     4 years ago
    0

    Hi,

    No, it does not track coupons setup for specific shopper groups, but it is easy enough to add. Sending you a private message.
  • Default avatar
    serena    
     4 years ago
    0

    i would like to be able to show available coupon too.. even with shopper groups it could be good! a page to show up the last active coupon for the shopper group the connected user belongs (even anonymous group) would be really awesome! is it possible?
  • Your avatar
    aleksius    
     2 years ago
    0

    Hello.
    "but it is easy enough to add. Sending you a private message." - I also need to do this. I need that coupons for group appear for every buyer.

    Use Joomla 2.5.22, AwoCoupon Pro 2.2.8, VirtueMart 2.6.6.

    Thanks in advance for your reply.
  • Your avatar
    seyi    
     2 years ago
    0

    Hello,

    Here are the edits I originally gave out, may need an adjustment or 2. One other note, this is specifically for Virtuemart.




    www/components/com_awocoupon/models/coupons.php, around line 35 is this:
    <?php
                    $current_date 
    date('Y-m-d H:i:s');
                    
    $sql 'SELECT u.coupon_id,c.num_of_uses_type,c.num_of_uses
                              FROM #__awocoupon_user u
                              JOIN #__awocoupon c ON c.id=u.coupon_id
                             WHERE c.estore="'
    .MYESTORE.'" AND u.user_id='.$user->id.' AND c.published=1
                               AND ( ((c.startdate IS NULL OR c.startdate="")     AND (c.expiration IS NULL OR c.expiration="")) OR
                                     ((c.expiration IS NULL OR c.expiration="") AND c.startdate="'
    .$current_date.'") OR
                                     (c.startdate="'
    .$current_date.'")
                                   )'
    ;
    ?>


    Change it to this
    <?php
                    $sql 
    'SELECT virtuemart_shoppergroup_id FROM #__virtuemart_vmuser_shoppergroups WHERE virtuemart_user_id='.$user->id;
                    
    $this->_db->setQuery($sql);
                    
    $shopper_group_id $this->_db->loadResult();
                    if(empty(
    $shopper_group_id)) {
                        
    $this->_db->setQuery('SELECT virtuemart_shoppergroup_id FROM #__virtuemart_shoppergroups WHERE published=1 AND `default`=1');
                        
    $shopper_group_id $this->_db->loadResult();
                    }
                    
    $current_date date('Y-m-d H:i:s');
                    
    $sql 'SELECT u.coupon_id,c.num_of_uses_total,c.num_of_uses_customer
                              FROM #__awocoupon_user u
                              JOIN #__awocoupon c ON c.id=u.coupon_id
                             WHERE c.estore="'
    .AWOCOUPON_ESTORE.'" AND u.user_id='.$user->id.' AND c.published=1
                               AND ( ((c.startdate IS NULL OR c.startdate="")     AND (c.expiration IS NULL OR c.expiration="")) OR
                                     ((c.expiration IS NULL OR c.expiration="") AND c.startdate="'
    .$current_date.'") OR
                                     (c.startdate="'
    .$current_date.'")
                                   )
                                  
                                                    UNION
                                  
                            SELECT u.coupon_id,c.num_of_uses_total,c.num_of_uses_customer
                              FROM #__awocoupon_usergroup u
                              JOIN #__awocoupon c ON c.id=u.coupon_id
                             WHERE c.estore="'
    .AWOCOUPON_ESTORE.'" AND u.shopper_group_id='.$shopper_group_id.' AND c.published=1
                               AND ( ((c.startdate IS NULL OR c.startdate="")     AND (c.expiration IS NULL OR c.expiration="")) OR
                                     ((c.expiration IS NULL OR c.expiration="") AND c.startdate="'
    .$current_date.'") OR
                                     (c.startdate="'
    .$current_date.'")
                                   )'
                            
    ;
    ?>

  • Your avatar
    aleksius    
     2 years ago
    0

    Thank you. Today or tomorrow I'll check it and write to you.
  • Your avatar
    aleksius    
     2 years ago
    0

    Unfortunately, did not help. You wrote about AwoCoupon Pro version 2.2.8 or 2.2.9? I tried on AwoCoupon Pro 2.2.8
  • Your avatar
    seyi    
     2 years ago
    0

    Hello,

    No, this code was written a long time ago. Did you receive any errors? Try changing MYESTORE to AWOCOUPON_ESTORE. To see if there is a database error, try setting debug mode to yes in global configuration and refreshing the page.
  • Your avatar
    aleksius    
     2 years ago
    0

    Yes. There is an error:

    500 - JDatabaseMySQLi::query: 1054 - Unknown column 'c.num_of_uses_type' in 'field list' SQL=SELECT u.coupon_id,c.num_of_uses_type,c.num_of_uses FROM lcdf0_awocoupon_user u JOIN lcdf0_awocoupon c ON c.id=u.coupon_id WHERE c.estore="virtuemart" AND u.user_id=521 AND c.published=1 AND ( ((c.startdate IS NULL OR c.startdate="") AND (c.expiration IS NULL OR c.expiration="")) OR ((c.expiration IS NULL OR c.expiration="") AND c.startdate<="2014-07-05 14:30:40") OR ((c.startdate IS NULL OR c.startdate="") AND c.expiration>="2014-07-05 14:30:40") OR (c.startdate<="2014-07-05 14:30:40" AND c.expiration>="2014-07-05 14:30:40") ) UNION SELECT u.coupon_id,c.num_of_uses_type,c.num_of_uses FROM lcdf0_awocoupon_usergroup u JOIN lcdf0_awocoupon c ON c.id=u.coupon_id WHERE c.estore="virtuemart" AND u.shopper_group_id=3 AND c.published=1 AND ( ((c.startdate IS NULL OR c.startdate="") AND (c.expiration IS NULL OR c.expiration="")) OR ((c.expiration IS NULL OR c.expiration="") AND c.startdate<="2014-07-05 14:30:40") OR ((c.startdate IS NULL OR c.startdate="") AND c.expiration>="2014-07-05 14:30:40") OR (c.startdate<="2014-07-05 14:30:40" AND c.expiration>="2014-07-05 14:30:40") )

    JDatabaseMySQLi::query: 1054 - Unknown column 'c.num_of_uses_type' in 'field list' SQL=SELECT u.coupon_id,c.num_of_uses_type,c.num_of_uses FROM lcdf0_awocoupon_user u JOIN lcdf0_awocoupon c ON c.id=u.coupon_id WHERE c.estore="virtuemart" AND u.user_id=521 AND c.published=1 AND ( ((c.startdate IS NULL OR c.startdate="") AND (c.expiration IS NULL OR c.expiration="")) OR ((c.expiration IS NULL OR c.expiration="") AND c.startdate<="2014-07-05 14:30:40") OR ((c.startdate IS NULL OR c.startdate="") AND c.expiration>="2014-07-05 14:30:40") OR (c.startdate<="2014-07-05 14:30:40" AND c.expiration>="2014-07-05 14:30:40") ) UNION SELECT u.coupon_id,c.num_of_uses_type,c.num_of_uses FROM lcdf0_awocoupon_usergroup u JOIN lcdf0_awocoupon c ON c.id=u.coupon_id WHERE c.estore="virtuemart" AND u.shopper_group_id=3 AND c.published=1 AND ( ((c.startdate IS NULL OR c.startdate="") AND (c.expiration IS NULL OR c.expiration="")) OR ((c.expiration IS NULL OR c.expiration="") AND c.startdate<="2014-07-05 14:30:40") OR ((c.startdate IS NULL OR c.startdate="") AND c.expiration>="2014-07-05 14:30:40") OR (c.startdate<="2014-07-05 14:30:40" AND c.expiration>="2014-07-05 14:30:40") )

    Call stack    
    #        Function        Location    
    1        JSite->dispatch()        Z:\home\localhost\www\puv\index.php:42    
    2        JComponentHelper::renderComponent()        Z:\home\localhost\www\puv\includes\application.php:194    
    3        JComponentHelper::executeComponent()        Z:\home\localhost\www\puv\libraries\joomla\application\component\helper.php:348    
    4        require_once()        Z:\home\localhost\www\puv\libraries\joomla\application\component\helper.php:380    
    5        JController->execute()        Z:\home\localhost\www\puv\components\com_awocoupon\awocoupon.php:31    
    6        AwoCouponController->display()        Z:\home\localhost\www\puv\libraries\joomla\application\component\controller.php:761    
    7        JController->display()        Z:\home\localhost\www\puv\components\com_awocoupon\controller.php:26    
    8        AwoCouponViewCoupons->display()        Z:\home\localhost\www\puv\libraries\joomla\application\component\controller.php:722    
    9        JView->get()        Z:\home\localhost\www\puv\components\com_awocoupon\views\coupons\view.html.php:22    
    10        AwoCouponModelCoupons->getData()        Z:\home\localhost\www\puv\libraries\joomla\application\component\view.php:386    
    11        JDatabase->loadObjectList()        Z:\home\localhost\www\puv\components\com_awocoupon\models\coupons.php:65    
    12        JDatabaseMySQLi->execute()        Z:\home\localhost\www\puv\libraries\joomla\database\database.php:1126    
    13        JError::raiseError()        Z:\home\localhost\www\puv\libraries\joomla\database\database\mysqli.php:396    
    14        JError::raise()        Z:\home\localhost\www\puv\libraries\joomla\error\error.php:251


    Nothing to worry about. From July 7, 2014 to July 14, 2014 I will be on vacation. It is not urgent and fundamental question. Thank you.
  • Your avatar
    seyi    
     2 years ago
    0

    Ok, I have updated the post above with the correct sql statement now. Some database fields have changed since the script was written. Basically you want to change

    c.num_of_uses_type,c.num_of_uses


    to

    c.num_of_uses_total,c.num_of_uses_customer


    And that should do it.
  • Your avatar
    aleksius    
     2 years ago
    0

    Yes. Thank you! It worked.