Prestashop Gift vouchers overpayment


  • Default avatar
    giles0    
     10 years ago
    0

    Hi

    I'me using Prestashop 1.5.6.2 and latest AwoCoupon Pro. I've been through initial tutorial to set up some Gift Vouchers. Here's my confusion:

    1. Using a test user account I first puchase a Gift Voucher for £5.00 (inc VAT value) value - all fine.

    2. I then create an order for an item with value £1.75 (exluding VAT at 20%), that incurrs shipping at £2.50 including VAT. I then apply my £5 voucher.

    In the cart the voucher line indicates a a discount of -£4.25 = seems correct as total goods plus shipping = £4.25
    Total at the bottom of the order is now 0.00 and I process the order.

    In AwoCoupon that gift certificate now shows balance of £0.75 - again makes sense.

    HOWEVER:

    When I placed the above order Prestashop generated an email:

    A voucher has been created in your name with the reference YDYDYLANZ.

    Voucher code: 4423f55ab9530da6, in the amount of £2.79.

    Simply copy/paste this code during the payment process for your next order.

    eh??

    Why has that been generated? The code specified does not work if entered, however the original AwoCoupon gift certificate code does still work with remainign value of 0.75 as expected. I've tried this several time and cannot see any reason why that is generated. I can't even make sense of the value it generates.

    The only clue I could find in this forums was perhaps to set:

    Enable Store Coupons in config. Even set to No this still happens.

    Any help appreciated.

    Thanks



  • Your avatar
    seyi    
     10 years ago
    0

    Hello,

    The generated coupon code 4423f55ab9530da6 is not coming from AwoCoupon. You must have another program is doing this, and likely you will find the code in Prestashop price rules. If you had AwoRewards, it can do this too but I do not think that is the case in your site.

    And the option "Enable store coupons" allows you to enable or disable cart rule coupon codes.
  • Default avatar
    giles0    
     10 years ago
    0

    Ok this is really strange...

    There was only one Free Shipping Cart Rul set up in the system, so I removed it.

    Now the box to enter a discount or voucher dissapears from the One Page Checkout screen. I can get it to re-appear again by temoving the {if $voucherAllowed}{/if} from around it, but then a discount code is not applied to the order. So this this seems to be that UNLESS you have at least one existing cart rule setup there is no way to enter vouchers?

    So I create a dummy cart rule that really does not do anything, after which my voucher entry field works again and voucher displayed on order line etc...

    HOWEVER

    I then place the order and bam... another email from Prestashop saying:

    A voucher has been created in your name with the reference TZHNAKRLU.

    Voucher code: c41c6cee8a2c59d4, in the amount of £2.81.

    Simply copy/paste this code during the payment process for your next order.

    where is this coming from... I have just ONE dummy cart rule that does nothing!!
  • Your avatar
    seyi    
     10 years ago
    0

    Hello,

    I am really not sure. Have you looked in Price rules->Marketing to see if something there is enabled that could be causing it? Also at what stage exactly do you get this? On order creation? On payment accepted? etc
  • Default avatar
    giles0    
     10 years ago
    0

    Hi

    No, there is nothing under Marketing.

    I've also posted help in PS forums as I'm still confused by two things

    1. Is it expected that for AwoCoupon to work there must be at least ONE existing price rule set up in PS?

    As it seems to me that if there are not any existing cart rules the standard voucher/coupon entry field in the default template is not displayed regardless of what you have created in AwoCoupon. This seems a little strange to me, and something that should maybe be tested/mentioned in documentation.

    2. As mentioned, I'm trying to find out if there is a default behaviour in PS that automatically detects an overpayment and sends vouchers i.e. what seems to be happening.

    If there IS some default behaviour then I think there should be way in AwoCoupon to disable it, otherwise coupon overpayments will always result in this spurios email.

    Thanks

    PS Email is sent after order is order is flagged as good shipped.
  • Your avatar
    seyi    
     10 years ago
    0

    Hello,

    1) this is a prestashop default behavior. When you first install AwoCoupon it automatically updates the configuration that shows the coupon box in the front end. If after that you delete all your prestashop coupons, then prestashop removes the configuration. In reality, it does not matter if you have prestashop cart rules or because you can disable them in awocoupon->configuration->Enable store coupons

    2) Something seems to be off somewhere. I tracked the code down, and it is displaying the email from www/mail/en/voucher.html, from within the code www/classes/PaymentModule.php, in the if statement starting at 425
    <?php
            
    if (count($order_list) == && $values['tax_incl'] > ($order->total_products_wt $total_reduction_value_ti) && $cart_rule['obj']->partial_use == && $cart_rule['obj']->reduction_amount 0)
    ?>


    Within this the partial_use has to be set to 1 for this to be triggered. AwoCoupon does not set the partial_use to 1, it is set to 0, and you can see this in www/override/classes/Cart.php.

    I would suggest just making sure all the correct overrides are there, you can find them using this:
    https://awodev.com/documentation/awocoupon-pro/installation
    go to the prestashop tab, the last section

    After that, go to www/cache and delete or rename class_index.php. Then refresh the front end and try it again.
  • Default avatar
    giles0    
     10 years ago
    0

    Hi my apologies for long delay, but I was on leave. Ok, returning to this issue...

    1) I'm afraid I still don't understand this. As I said, regardless of AwoCoupon settings, on my one page checkout, if there are NO cart rules in PS then the coupon entry box dissapears i.e. even if vouchers have been issued through AwoCoupon there is nowhere for user to enter them. This seems plain wrong to me.

    Note: Regarding AwoCoupon settings... If I set Enable Store Coupons to No and click Save, it immediately shows the field as value Yes again. Is that right?

    2) I've checked. All those overrides are there and I again deleted class_index.php and refreshed. However my issue still remains i.e. whenever I overpay with an AwoCoupon a PS voucher email is generated to the user.

    Where do we go from here?
  • Your avatar
    seyi    
     10 years ago
    0

    Hello,

    1) you can add a cart rule and disable it
    And no, if you set a setting in configuration, it should not reset back to the original

    2) the coupon is not coming from AwoCoupon so not really sure how to advice. if you like I can have a quick look but you would need to send a private message with temporary admin/ftp access.
  • Default avatar
    giles0    
     10 years ago
    0

    Hi

    1) Not correct. If I create one cart rule and it is active then one page checkout shows field to enter voucher. If I disable that cart rule then the field dissapears. So currently the only way I can trigger the voucher entry field on the one page checkout is to have at least one active standard PS cart rule.

    Regarding the setting, clearly something is wrong, as I cannot set that field to No currently.

    Do you gave list of new tables/fields that AwoCoupon creates/modifies? I'm thinking next step would be to try and delete all references to the module and re-install, assuming that this is not done as part of an Uninstall.

    2) Thank you for offer of assinstance. The site I'm working on is clone of the live site so I have freedom to test in any way necessary, however before that I would like to try the cleanest uninstall I can, then re-install and repeat my tests.
  • Default avatar
    giles0    
     10 years ago
    0

    I Uninstalled AwoCoupon, which gave error message but still uninstalled anyway (apologoes dod not note mesage). I then made sure module folder had been deleted and the override files. I also then deleted all the AwoCoupon tables in the database (seems these are only the prefixed ones - I soubled checked off list in install sql file as well)

    I then uploaded and installed AwoCoupon again. My previous version was 1.2.2 so I took opportunity to uploaded 1.2.3 this time, and activated my temp lience.

    Ok, now before I do anything else... I've gone into Configuaration and set Enable Store Coupons to No, and clicked Save. When screen refreshes that setting is back to Yes again!

    Please advise on whether this is correct as if it;s not then I think I need to solve this first.

  • Default avatar
    giles0    
     10 years ago
    0

    Ok. what seems to be happening here is that when Enable Store Coupons is set to No the value enable_store_coupon in ps_awocoupon_config is being set to Null, and the code in config.php is then defaulting display of Enable Store Coupons to Yes. On save the config update code should be setting values to 0 or 1 not back to Null again, right?

    Failing that, if you are using Null to record No state then, I think code in config.php should be:

    'enable_store_coupon'=>$params->get('enable_store_coupon', 0),
  • Default avatar
    giles0    
     10 years ago
    0

    So back to square one.. after 4 hours of work on this today... I test for original problem:

    I issue a gift certificate for £10
    I enter it on an order for total value £4.25, it's accepted, BUT
    Prestashop then sends me a 'prestashop' voucher for £2.08!!!

    WHY?????

  • Your avatar
    seyi    
     10 years ago
    0

    Yes, this will be fixed in the next version, which I will be releasing today or tomorrow.
  • Your avatar
    seyi    
     10 years ago
    0

    The installation is fine.
  • Your avatar
    seyi    
     10 years ago
    0

    Ok, so I was originally testing on 1.5.6.0. I then decided to upgrade to your version 1.5.6.2 and was able to produce the problem. So have a fix now.

    In www/override/classes/Cart.php, towards the very end of the file is this:
    <?php
                $arrdiscount
    ['reduction_amount'] = $arrdiscount['obj']->reduction_amount 1;
                
    $discounts[] = $arrdiscount;
    ?>


    Change it to this:
    <?php
                $arrdiscount
    ['reduction_amount'] = $arrdiscount['obj']->reduction_amount 1;
                
    $arrdiscount['obj']->partial_use 0;
                
    $discounts[] = $arrdiscount;
    ?>


    That will solve the problem.