awo coupon error messages problem and workaround

  • Your avatar
     5 years ago

    I had a strange problem with AWO Coupon with VM 1.1.7, which I hope I would not find in the pro version.
    the problem:
    Whenever a user types in a coupon code, no matter, which reason of the following:
    - User is not eligible for using that coupon,
    - Coupon/Gift code not present in db,
    - coupon code cannot be used for the products in basket,
    - basket total value is too low,
    - etc
    awo coupon shows the same error message for all these problems.
    If you give only one general message, the user won't know, what was wrong with his coupon code and calls in for help.

    In ps_coupon_process.php there are also several error messages, which seem not to be passed back to VM (or I am mistaken), is based on these, I've created a workaround.
    (Of course, If anyone has a better idea or these error messages are passed back to VM, then pls be so kind and share your thoughts with me)

    Anyway, the workaround is:

    at ps_coupon_process.php, in function return_false:

    line 197 (or so), comment out:
    $GLOBALS['coupon_error'] = $VM_LANG->_('PHPSHOP_COUPON_CODE_INVALID');

    at next line, insert:
    $message = str_replace(" ","_",preg_replace('/[,.:;-]/','',$message)); // converting the lowercase error messages to VM_LANG message titles. if you are more experienced in php, be so kind and write a better replace mechanism for this. :-P
    $GLOBALS['coupon_error'] = "VM_COUPON_".strtoupper($message); // pass back the error message.

    at \components\com_virtuemart\themes\-YOURTHEME-\templates\common\couponField.tpl.php change:
    around line 31, change:
    if( !empty($GLOBALS['coupon_error']) ) { ...}
    if( !empty($GLOBALS['coupon_error']) ) {
        echo '<strong class="error">' . $VM_LANG->_($GLOBALS['coupon_error']). "</strong>

    at \administrator\components\com_virtuemart\languages\common\-YOURLANGUAGE-.php, add:
        //awocouponmessages for VM
    'VM_COUPON_MINIMUM_VALUE_NOT_REACHED' => 'Minimum coupon usage value not reached.',
        'VM_COUPON_NO_RECORD_MIGHT_BE_UNPUBLISHED_OR_EXPIRED' => 'Your coupon code is expired or it\'s not present.',
        'VM_COUPON_NOT_ON_PRODUCT_LIST' => 'THis code cannot be used for this product.',
        'VM_COUPON_TOTAL_ALREADY_USED_GIFTCERT_MAX_NUMBER_OF_TIMES' => 'This gift code was already used by its maximum possible time.',
        'VM_COUPON_ALREADY_USED_COUPON_MAX_NUMBER_OF_TIMES' => 'This couponcode was already used by its maximum possible time.',
        'VM_COUPON_NOT_ON_USER_LIST' => 'You\'re not allowed to use this coupon.',
        'VM_COUPON_USER_NOT_LOGGEDIN' => 'Please log in!'

    ...and that's it, You get different messages for different types of errors, as it should be.
  • Your avatar
     5 years ago


    in the pro version you can change the error messages displayed in awocoupon->configuration.
  • Default avatar
     5 years ago

    "interesting. in the pro version you can change the error messages displayed in awocoupon->configuration."
    Are these error messages compatible with joomfish too?
    I need to use you software in a multi-language site.

    Thanks in advance:
  • Your avatar
     5 years ago

    yes, joomfish is supported for the error messages.