GiftCert not changing to Balance and assigning Customer Balance after use.


  • Default avatar
    Datalynk    
     3 years ago
    0

    We have imported a large number of GiftCerts assigned to users to be used and the balance after use assigned to customer balance.


    Looking at the database the GiftCert is used without issue, however the Customer Balance entry is NOT created and the remaining balance not showing. 

    I am aware of the issues with import as all your documentation is out dated with regarded to managing assets, and have had no success getting any support. 

    Updated documentation for import and for using API functions would be very helpful, however for the moment just some help with this issue would be much appreciated.

  • Your avatar
    seyi    
     3 years ago
    0

    Hello,

    Customer balances are created for unrestricted gift certificates, where the below option is set to yes in awocoupon configuration:
    Automatically add valid Gift Certificate to Balance on coupon usage
  • Your avatar
    seyi    
     3 years ago
    0

    Think I understand what you mean now, even with the restriction of user specific gift certificate, as long as that is the only restriction, then it should still add the balance to the customer balance.  That makes sense.  Here is what you can to to make that happen.  In the file:

    www/administrator/components/com_awocoupon/awocoupon/library/class-awocoupon-library-coupon.php, around line 367 is this
               AND (c.params IS NULL OR c.params=""

    Change it to this:
               AND (c.params IS NULL OR c.params="" OR c.params=\'{"asset":[{"rows":{"user":{"type":"user","mode":"include"}}}]}\')

    And around line 381 is this:
    <?php
            $test 
    AC()->db->get_value'SELECT id FROM #__awocoupon_asset WHERE coupon_id=' $coupon_row->id );
            if ( ! empty( $test ) ) {
                if ( $is_display_error ) {
                    AC()->helper->set_messageAC()->lang->__'Restricted Gift Certificate' ), 'error' );
                }
                return false;
            }
    ?>

    Change it to this:
    <?php
            $test 
    AC()->db->get_objectlist'SELECT * FROM #__awocoupon_asset WHERE coupon_id=' $coupon_row->id );
            if ( ! empty( $test ) && count$test ) > ) {
                if ( $is_display_error ) {
                    AC()->helper->set_messageAC()->lang->__'Restricted Gift Certificate' ), 'error' );
                }
                return false;
            }
            if ( ! empty( $test ) ) {
                if ( $test[0]->asset_type != 'user' ) {
                    if ( $is_display_error ) {
                        AC()->helper->set_messageAC()->lang->__'Restricted Gift Certificate' ), 'error' );
                    }
                    return false;
                }
                $user AC()->helper->get_user();
                if ( $test[0]->asset_id != $user->id ) {
                    if ( $is_display_error ) {
                        AC()->helper->set_messageAC()->lang->__'Restricted Gift Certificate' ), 'error' );
                    }
                    return false;
                }
    ?>

    Should work as you expect now.
  • Default avatar
    Datalynk    
     3 years ago
    0

    OK Thank you! Will give it a try