• Resolved alkateb

    (@alkateb)


    Hello, I’m trying to create orders programmatically, and to do that, I am making a debit transaction with the total cart amount for the user making the purchase, using this code:

    woo_wallet()->wallet->debit($apiuser->id, $order->get_total(), 'For order #' . $order->id, $order->id);

    But for some reason, this isn’t working as expected, the _current_woo_wallet_balance meta is not updating when I create an order this way, and I am relying on this value to decide whether or not the user has sufficient balance, because some users have over 10k transactions and I believe this will make calculating the actual balance way too slow, I even had to edit the plugin’s transactions page, and show the meta value instead because it took about 1 minute to load.

    Right now, _current_woo_wallet_balance says 14.8 for my test case, and the website shows an actual negative balance of: -35.20
    So my question is: Do I ABSOLUTELY have to rely on woo_wallet()->wallet->get_wallet_balance method for an accurate balance check?

    And why isn’t the user meta updating even though I’m calling the debit method, which in turn calls recode_transaction, which obviously is updating the _current_woo_wallet_balance meta.

    To be clear, I’m calling WordPress from an external file (My API) using require('wp-blog-header.php'); and in that file I am making the call I mentioned above, maybe I need to bind this call to an action like wp_loaded? Or am I missing other calls to woo_wallet API?

    Thanks

    • This topic was modified 4 years ago by alkateb.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘current balance meta not updating’ is closed to new replies.