"Enable Store Coupons" does not display proper message


  • Default avatar
    romatawo    
     10 years ago
    0

    Dear Awo,

    I am not sure if you still provide support. I am a new customer and sent you an email and have not received any response yet.

    Anyway, I have a problem related to AWO coupons. When “Enable Store Coupons” is on, it lets the user to enter coupons created in VM. However, when user enters a code that does not exist, system display a message saying the coupon has been successfully added. When this option is off, proper message displays based on valid/invalid coupon.

    I’d like to use VM coupons along with AWO, but when invalid coupon is entered, I need to display a message letting the user know that it does not exist.

    Please help to fix the bug.

    Thanks.
  • Your avatar
    seyi    
     10 years ago
    0

    Hello,

    Of course we provide support. I have not seen any emails on this topic apart from the one you sent after this post.

    What version of AwoCoupon are you using? Are you using a one page extention?
  • Default avatar
    simon29    
     10 years ago
    0

    Has anyone found an answer to this problem.
  • Your avatar
    seyi    
     10 years ago
    0

    Hello,

    Here is a solution,
    in www/administrator/components/com_awocoupon/helpers/estore/virtuemart/couponhandler.php, around line 97 is
    <?php
        
    if(empty($tmp)) {
            
    $db->setQuery('SELECT virtuemart_coupon_id FROM #__virtuemart_coupons WHERE coupon_code='.$db->Quoteawolibrary::dbEscape(trim($_code))) );
            
    $tmp $db->loadResult();
            if(!empty(
    $tmp)) {
                
    // run coupon through virtuemart system
                
    $code $instance->vmcart->couponCode;
                
    $instance->initialize_coupon();
                
    $instance->vmcart->couponCode $code;
                return 
    null;
            }
        }
    ?>


    Update it to this:
    <?php
        
    if(empty($tmp)) {
            
    $db->setQuery('SELECT virtuemart_coupon_id FROM #__virtuemart_coupons WHERE coupon_code='.$db->Quoteawolibrary::dbEscape(trim($_code))) );
            
    $tmp $db->loadResult();
            if(!empty(
    $tmp)) {
                
    // run coupon through virtuemart system
                
    $code $instance->vmcart->couponCode;
                
    $instance->initialize_coupon();
                
    $instance->vmcart->couponCode $code;
                return 
    null;
            }
            return 
    JText::_('COM_VIRTUEMART_COUPON_CODE_INVALID');
        }
    ?>


    That should fix te problem.
  • Default avatar
    simon29    
     10 years ago
    0

    Many Thanks for the reply but unfortunately it doesn't solve the problems.
    The code in my version once edited is as follows:
    <?php
            
    //------START VIRTURMART COUPON SYSTEM ----------------------------------------------------------------------------------------------
            
    if($_code!='('.JText::_('COM_AWOCOUPON_CP_DISCOUNT_AUTO').')' && $instance->params->get('enable_store_coupon'0) == 1) {
                
    $db->setQuery'SELECT id FROM #__awocoupon WHERE estore="virtuemart" AND coupon_code='.$db->Quoteawolibrary::dbEscape(trim($_code))) );
                
    $tmp $db->loadResult();
                if(empty(
    $tmp)) {
                    
    $db->setQuery('SELECT virtuemart_coupon_id FROM #__virtuemart_coupons WHERE coupon_code='.$db->Quoteawolibrary::dbEscape(trim($_code))) );
                    
    $tmp $db->loadResult();
                    if(!empty(
    $tmp)) {
                        
    // run coupon through virtuemart system
                        
    $code $instance->vmcart->couponCode;
                        
    $instance->initialize_coupon();
                        
    $instance->vmcart->couponCode $code;
                        return 
    null;
                    }
                    return 
    JText::_('COM_VIRTUEMART_COUPON_CODE_INVALID');
                }
            }
            
    //------END   VIRTURMART COUPON SYSTEM ----------------------------------------------------------------------------------------------
    ?>

    As you can see it's enbeded within a larger function. I don't know if that will make any difference?

    This still displays the following message at the top of the page: Discount Code successfully added

  • Your avatar
    seyi    
     10 years ago
    0

    Hello,

    I am not sure then as that fixed the problem when testing this out. Are you using a commercial checkout system? If so can you disable it to see if you still get the error?

    If you like, I can look at it but you would need to send me temporary admin and ftp access through a private message.
  • Default avatar
    simon29    
     10 years ago
    0

    Hi

    I think I've got this working now, I just added an 'else' statement to your soution:

    } else {
    return JText::_('COM_VIRTUEMART_COUPON_CODE_INVALID');
    }

    rather than just:

    return JText::_('COM_VIRTUEMART_COUPON_CODE_INVALID');

    Thanks again.