Awocoupon Free (Version: 2.0.21) not working correctly on VM 3.0.12 - 3.0.14 when user is registered and logged in


  • Default avatar
    MMC Edizioni    
     8 months ago
    0

    I have upgraded my website to VM 3.0.14, and I would like to use the Free Awocoupon version before considering to buy the pro one.
    But I have noted in my test that it's not working as espected in a specific behaviour...

    You can verify the issue in this way:

    1) make a coupon and mark it as active
    2) register as new user BEFORE going to check out and then login, or login with existing registered user account.
    3) add a product to your cart
    4) go to checkout and try to redeem the coupon

    After this operations, your coupon is correctly subtracted from the total amount BUT it is NOT displayed on cart: the coupon section of cart page shows only the string "change your coupon" inside the coupon field, but IT DOESN'T show both the coupon discount name and its amount (if you try the same action chain as guest, it works right, and name/amount of coupon are displayed as expected)

    Only hitting again the SAVE COUPON button or the CONTINUE ORDER button you'll get the coupon value/amount displayed.

    I have also noticed that this issue also exists in VM 3.0.12

    Could you please help me to fix it asap?

    Thank you in advance

    Regards
  • Your avatar
    seyi    
     8 months ago
    0

    Hello,

    I have tested this in both vm 3012 and 3014 and cannot reproduce the problem. The coupon value and amount correctly show after entering the coupon. I tried it both as a guest and a registered user. Are you using an external checkout system? If so can you temporarily disable it and try it again to see if that is the issue?
  • Default avatar
    MMC Edizioni    
     8 months ago
    0

    No, I'm not using any external checkout, only basic WM 3.x one. I have also disabled any template modding, setting a standard joomla template instead of my modded one, but I can't understand where is the problem...
  • Default avatar
    MMC Edizioni    
     8 months ago
    0

    It may be I have found the issue, not related to any external component, but probably due to some sort of character wrong/lacking field encoding in your component.
    I was testing your component using a coupon having all UPPERCASE letters: but, when trying to redeem it, I was introducing the coupon itself in LOWERCASE!!! This leaded to the issue.
    In my situation, I made a coupon named 'TEST' but was trying to redeem it using the string 'test'.
    I have also tested the reversed situation, having a coupon named 'test' and redeeming it using 'TEST', and the results it's the same: in that specific situation, the coupon is corretly used & calculated, but the coupon name/amount don't appear in cart.
    It also happen if you don't exactly use the correct uppercase-lowercase as typed when making the coupon: if you chang at least one char from lowercase to uppercase (or viceversa), you get the coupon used but not displayed.

    I suggest you to force the coupon creation to ignore the lowercase-uppercase map, considering only the character sequence and not the case.

    Can you please verify now if it also happens to you in that way? End eventually fix it?

    Thank you again for your support
  • Your avatar
    seyi    
     8 months ago
    0

    Hello,

    Still cant produce it, even with changing cases. By default, in the free version, the coupon is case insensitive. In pro it is the opposite.

    Mysql string comparisons are case insensitive, which is what AwoCoupon uses. It does not explicitly make the check lower case. So I wonder what your awocoupon table looks like. Can you
    show create table #__awocoupon_vm;


    And post the result? You would need to change #__ to your actual prefix.
  • Default avatar
    MMC Edizioni    
     8 months ago
    0

    Here the query result:

    j3vm3mmc_awocoupon_vm CREATE TABLE `j3vm3mmc_awocoupon_vm` (
    `id` int(16) NOT NULL AUTO_INCREMENT,
    `coupon_code` varchar(32) NOT NULL DEFAULT '',
    `num_of_uses` int(11) NOT NULL DEFAULT '0',
    `coupon_value_type` enum('percent','total') NOT NULL DEFAULT 'percent',
    `coupon_value` decimal(12,2) NOT NULL DEFAULT '0.00',
    `min_value` decimal(12,2) DEFAULT NULL,
    `discount_type` enum('specific','overall') NOT NULL DEFAULT 'overall',
    `function_type` enum('coupon','giftcert') NOT NULL DEFAULT 'coupon',
    `function_type2` enum('product','category') DEFAULT NULL,
    `startdate` date DEFAULT NULL,
    `expiration` date DEFAULT NULL,
    `coupon_description` varchar(255) DEFAULT NULL,
    `published` tinyint(4) NOT NULL DEFAULT '1',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8

    I added a further field named 'coupon_description', to better manage coupons in frontend, but the remaining fields should still be like the original ones.

    I also remember you that it strangely happens only when logged in as registered VM user: in that case, the coupon is correctly used in cart calculation, but its name and its amount are not displayed in cart imediately after coupon usage; I must hit twice the save or the continue order button to get them displayed. If I put in the field the coupun using the exact case, it works normally.
  • Your avatar
    seyi    
     8 months ago
    0

    This is just strange. No, I still cannot reproduce it.

    Do you have an override of the coupon display? Do you have this file on your server:

    www/templates/[YOUR_TEMPLATE]/html/com_awocoupon/coupondelete/default.php

    ??

    If so can you rename it or remove it?

    At this point out of options if that is not it. If you like I would be happy to look directly at the problem, would just need you to send a private message with temporary admin and ftp access.
  • Default avatar
    Robertoo    
     4 months ago
    0

    I have exactly the same problem. I am using AwoCoupon Free with VM3.0.16 on J3.5.1. and PHP 5.6.19. Standard Joomla! install with protostar template. I have not added any overrides.
    The problem only occurs when I have logged in (as a registered user or super user doesn't matter).
    If the entered coupon code does not have the exact same case as the stored code, the problem arises. If you hit the 'save' button again without entering a code, or if you click the 'update quantity in cart' button, the problem is gone.
    Also after clicking the checkout button, independent of whether I have accepted the terms, the problem is gone.

    I noticed that the program does find a code match in the db, in other words: the $coupon_row is NOT empty (function validate_coupon_code() in /administrator/.../vm_coupon.php).

    It has been puzzling me for many hours already...
  • Default avatar
    Robertoo    
     4 months ago
    0

    I had exactly the same problem (see my earlier post) and found a work-around. Before the entered coupon code is checked against the database, I convert both strings to upper case. This makes the whole process case insensitive and everything works well.
    Unfortunately it requires the hack of two files of the AWO core (AwoCoupon Free v2.0.22), which I don't like of course...
    I edited my copy of the original install package so that the change is included in all my future installs, but I hope that the bug will also be fixed in future releases by Awo.

    File vm_coupon.php in /administrator/components/com_awocoupon/helpers/

    > Change below code

    function validate_coupon_code() {
       ...
       $sql = 'SELECT id,coupon_code,num_of_uses,coupon_value_type,coupon_value,min_value,discount_type,function_type,function_type2
              FROM #__'.AWOCOUPON.' 
             WHERE published=1
               AND ( ((startdate IS NULL OR startdate="")     AND (expiration IS NULL OR expiration="")) OR
                     ((expiration IS NULL OR expiration="") AND startdate<="'.$current_date.'") OR
                     ((startdate IS NULL OR startdate="")     AND expiration>="'.$current_date.'") OR
                     (startdate<="'.$current_date.'"        AND expiration>="'.$current_date.'")
                   )
               AND coupon_code='.$db->Quote( awolibrary::dbescape($this->vmcoupon_code)).'';
       $db->setQuery( $sql );
       $coupon_row = $db->loadObject();
       $this->coupon_row = $coupon_row;
       ...


    > into this code (add a few lines after the SQL query):

    function validate_coupon_code() {
       ...
       ...
       $sql = 'SELECT id,coupon_code,num_of_uses,coupon_value_type,coupon_value,min_value,discount_type,function_type,function_type2
              FROM #__'.AWOCOUPON.' 
             WHERE published=1
               AND ( ((startdate IS NULL OR startdate="")     AND (expiration IS NULL OR expiration="")) OR
                     ((expiration IS NULL OR expiration="") AND startdate<="'.$current_date.'") OR
                     ((startdate IS NULL OR startdate="")     AND expiration>="'.$current_date.'") OR
                     (startdate<="'.$current_date.'"        AND expiration>="'.$current_date.'")
                   )
               AND coupon_code='.$db->Quote( awolibrary::dbescape($this->vmcoupon_code)).'';
       $db->setQuery( $sql );
       $coupon_row = $db->loadObject();
       $this->coupon_row = $coupon_row;

       // hack by Robertoo
       if ( isset($this->coupon_row->coupon_code) ) {
        $this->coupon_row->coupon_code = strtoupper($this->coupon_row->coupon_code);
       }
       // end of hack
       ...



    File awocoupon.php in /plugins/vmcoupon/awocoupon/

    > Change below code

    function plgVmValidateCouponCode($_code,$_billTotal) {
        
      $awo_file = JPATH_ADMINISTRATOR.'/components/com_awocoupon/helpers/vm_coupon.php';
      if(!file_exists($awo_file)) return null;
        
      if(!class_exists('vm_coupon')) require $awo_file;
      $vm_coupon = new vm_coupon();
      return $vm_coupon->vm_ValidateCouponCode($_code);
    }


    > into this code (add a few lines at the top):

    function plgVmValidateCouponCode($_code,$_billTotal) {
        
      // hack by Robertoo
      $_code = strtoupper($_code);
      // end of hack
        
      $awo_file = JPATH_ADMINISTRATOR.'/components/com_awocoupon/helpers/vm_coupon.php';
      if(!file_exists($awo_file)) return null;
        
      if(!class_exists('vm_coupon')) require $awo_file;
      $vm_coupon = new vm_coupon();
      return $vm_coupon->vm_ValidateCouponCode($_code);
    }

  • Your avatar
    seyi    
     4 months ago
    0

    Hello,

    Thanks for posting. It helped in reproducing the problem. It is now fixed in the latest free version, 2.0.23:

    https://awodev.com/products#com_awocoupon_free