Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Schaussi

    (@schaussi)

    Addition:
    As a better workaround, this seems to work for now:

    if (current_user_can("withdraw_wallet_balance"))
    {
    	add_filter('woo_wallet_disallow_negative_transaction', '__return_false');	
    }

    Edit: This might work for usual shop orders, but not for POS plugins, as this method does not seem to deliver an always up-to-date value for the given user.

    What currently works for me is to directly edit process_payment function and add to top:

    $underZero = $order->get_total( 'edit' ) > woo_wallet()->wallet->get_wallet_balance( get_current_user_id(), 'edit' );		
    		if ($underZero)
    		{
    			if (!(current_user_can("withdraw_wallet_balance")))
    			{
    				wc_add_notice( __( 'Payment error: ', 'woo-wallet' ) . sprintf( __( '(Custom error msg) Your wallet balance is low. Please add %s to proceed with this transaction.', 'woo-wallet' ), wc_price( $order->get_total( 'edit' ) - woo_wallet()->wallet->get_wallet_balance( get_current_user_id(), 'edit' ), woo_wallet_wc_price_args($order->get_customer_id()) ) ), 'error' );
    				return;
    			}
    		}

    And additionally, in functions.php:
    add_filter('woo_wallet_disallow_negative_transaction', '__return_false');

    • This reply was modified 7 years, 2 months ago by Schaussi.
    • This reply was modified 7 years, 2 months ago by Schaussi.
    • This reply was modified 7 years, 2 months ago by Schaussi. Reason: Added additional code
    • This reply was modified 7 years, 2 months ago by Schaussi.
    Thread Starter Schaussi

    (@schaussi)

    Nevermind, I had a look at the POS’ code and it seems to create a WC order’s total sum of 0,00. WC seems to correct this afterwards within the order, so one does not really notice that.

    For anyone who’s interested, as a workaround I changed the code to use the given SUBtotal (which is okay for me, but surely not for everyone).

    class-woo-wallet-payment-method.php -> line 119 -> change “order->get_total” to “order->get_subtotal”.

    Edit: Maybe a bit better, but also not clean at all:
    Within function process_payment, add after the first line:
    $order -> set_total($order -> get_subtotal());

    • This reply was modified 7 years, 2 months ago by Schaussi. Reason: Other workaround
    Thread Starter Schaussi

    (@schaussi)

    Hi @subratamal,

    thank you for your answer.
    I re-checked the theme and plugins but have not found the cause yet.
    IMHO when finishing the order, it tries to also pay the current negative wallet balance. This is useful e.g. if the payment method of the current order is e.g. cash, but not if he pays again via his (negative balanced) wallet.

    Example of an order confirmation email, I added some comments:
    SomeProduct 1 €2,00 // OK
    Zwischensumme: €2,00 //subtotal – OK
    Lieferung: Kostenlose Lieferung //free delivery – OK
    Zahlungsmethode: MyTestWallet //the payment method (wallet) – OK
    Via wallet: -€6,00 //the current negative wallet balance; this line causes the wrong sum!
    Via MyTestWallet: €8,00 //the wallet; should be €2,00
    Gesamt: €8,00 //total; should be €2,00

    So if the user had a balance of -6 € before, he has a balance of -14 € afterwards, but the product price was only 2 €…

    The “Via wallet” line should not exist here I think.

    I hope it’s more clear now what I mean.
    Please tell me if you need more details.

    Thank you!

    Edit:
    In woo-wallet-util.php, when I change function is_full_payment_through_wallet() to always return true, it seems to work correctly for my purposes.

    • This reply was modified 7 years, 10 months ago by Schaussi. Reason: Added Workaround

    Hi,
    this works basically, but does not subtract the balance correctly if the balance is already under 0.
    E.g. you have a balance of -2 and buy something with the price of 2.
    Curiously, the final balance is -6 instead of -4.
    Could you maybe correct this behavior in a future version?
    Thank you

    Hi,
    I tested the code above and unfortunately, if the user has a negative balance and buys something, the current negative balance value is also _added_ to the current sum of the order.
    E.g. if I have a wallet balance of -2 and order something with the price 10, my new balance is -14…
    The confirmation email shows an additional line “Via wallet” if the wallet balance was negative before, with the current negative value, and this value seems to be added to the order sum…

    Thread Starter Schaussi

    (@schaussi)

    Hi,

    I just tested a little modification, you would only need to add __() to the post title output.

    <?php echo __($significant_updated_post->post_title) ?>

    It would be great if you could include this change in the next version.

    Thank you,
    Regards

    Thread Starter Schaussi

    (@schaussi)

    Beim zweiten Versuch hat es nun seltsamerweise problemlos geklappt.
    Danke!

    Thread Starter Schaussi

    (@schaussi)

    that was really fast 🙂 works now, thank you

    Thread Starter Schaussi

    (@schaussi)

    Besten Dank für die rasche Behebung, läuft wieder einwandfrei!

Viewing 9 replies - 1 through 9 (of 9 total)