Gift certificate balance apply button not working in the cart


  • Default avatar
    david19    
     2 years ago  last edited 2 years ago
    0

    Hello. Enabled AwoCoupon balance function and added awocoupon balance module to the cart. When clicking to "apply_voucher_balance" button - it does not work, but if i activate in the configuration option "Automatically add balance to cart" and then click to apply_voucher_balance button - it works correctly and gives discount to order. Have there been such issues here on the forum before?
  • Your avatar
    seyi    
     2 years ago
    0

    Hello,

    The awocoupon balance module allows you to apply the balance in your account to the shopping cart.  Is that what you mean?

    Or are you trying to add a voucher to your account?  For that you need to go to this page for that:
    index.php?option=com_awocoupon&view=giftcerts

  • Default avatar
    david19    
     2 years ago
    0

    Yes, i mean applying balance to the shopping cart.
  • Default avatar
    david19    
     2 years ago  last edited 2 years ago
    0

    So i found, that this button calls task "apply_voucher_button", that calls cart_coupon_validate_balance() function in /awocoupon/helpers/estore/virtuemart/class-awocoupon-helper-estore-virtuemart-discount.php. In this function i tested deleting some return false conditions and came to conclusion, that the problem is in condition
    if ( $this->init() === false ) {
    return false;
    }

    In public function init( $prepare_data = true ) there is a code:

    if ( $this->get_checkout_extension() == 'vponepage' || empty( $new_cart->products ) ) {
    $new_cart->prepareCartData();
    }

    When i delete this condition - everything works fine. I forgot to mention that I have installed OnePage Checkout by Rupostel component, maybe thats the reason that something go wrong. I'll try to understand why this condition prevents applying balance to the cart.

    (Edit) The reason is in "empty( $new_cart->products )" condition exactly.

  • Default avatar
    david19    
     2 years ago
    0

    One more question about gift certificate balance. I have created in demo.awocoupon a coupon with 10% discount "coup1". I go to cart, apply gift certificate, then apply coup1 coupon. And they work together, despite the fact that i disabled the option "Multiple coupons" in awocoupon configuration. As you see in screenshot, it gives 33$ discount - thats my gift certificate balance, and also gives a 10% (5$) discount.


    In coup1 settings i turned on option "Exclude Gift Certificate Products" but it didn't work, the balance and coupons work together. How do i disable it?

  • Your avatar
    seyi    
     2 years ago
    0

    Hello,

    It is not a feature.  The balance is assumed to be the customer's money and does not count in the multiple coupons scenario.  Also 'Exclude gift certificate products' is for gift certificate products you are selling, you are excluding the coupon from working on those.

    If you really want to disable awocoupon balance working with coupons, and you have multiple coupons disabled completely, you can modify the code.  In
    \administrator\components\com_awocoupon\awocoupon\library\class-awocoupon-library-discount.php, around line 600 is this:
    <?php
                $coupon_awo_entered_coupon_ids 
    = array( array_pop$coupon_awo_entered_coupon_ids ) );
    ?>

    Right before that, add this:
    <?php
                
    if ( ! empty( $customer_balance_coupon_rows ) ) {
                    $coupon_awo_entered_coupon_ids = array();
                }
    ?>

  • Default avatar
    david19    
     2 years ago  last edited 2 years ago
    0

    It seems to work, thank you!

    Any ideas why in /awocoupon/helpers/estore/virtuemart/class-awocoupon-helper-estore-virtuemart-discount.php the condition in public function init( $prepare_data = true ) blocks applying the balance to the cart? When i delete this condition - balance is applying to cart normally. Can i just comment this condition and what it will cause?

    if ( $this->get_checkout_extension() == 'vponepage' || empty( $new_cart->products ) ) {
    $new_cart->prepareCartData();
    }


  • Your avatar
    seyi    
     2 years ago
    0

    Not sure what is causing it.  I have installed the latest version of AwoCoupon and Rupostel and it works fine for me when trying to apply the balance.