Support » Plugin: TeraWallet - For WooCommerce » Partial payments – no debit in wallet

  • Resolved minovec

    (@minovec)


    Hello sir,

    I have a strange issue. When customer chose partial payment in the checkout page, and then the customer choose other payment method (COD, bank transfer), the amount is not debited from customer wallet imediatelly, but I can see Via Wallet fee in the order details.

    When the customer chose credit card payment (status processing) the partial amount has been debited ok.

    I am using custom order statuses, and for example when customer chose COD, the first status of the order is set to pending and after that set to custom_COD_status automatically. For example bank transfer, the status of the order is set to pending and after that is set to custom_WAIT_status.

    I have following code in functions.php

    add_action('woocommerce_checkout_order_processed', 'process_woo_wallet_partial_payment', 40, 1);
    
    function process_woo_wallet_partial_payment($order_id) {
        $order = wc_get_order($order_id);
        if (get_post_meta($order_id, '_via_wallet_payment', true) && !get_post_meta($order_id, '_partial_pay_through_wallet_compleate', true)) {
            $transaction_id = woo_wallet()->wallet->debit($order->get_customer_id(), get_post_meta($order_id, '_via_wallet_payment', true), __('For order payment #', 'woo-wallet') . $order->get_id());
            if ($transaction_id) {
                $order->add_order_note(sprintf(__('%s paid through wallet', 'woo-wallet'), wc_price(get_post_meta($order_id, '_via_wallet_payment', true))));
                update_wallet_transaction_meta($transaction_id, '_partial_payment', true, $order->get_id());
                update_post_meta($order_id, '_partial_pay_through_wallet_compleate', $transaction_id);
            }
        }
    }

    but this code is not working. I don’t have ‘_via_wallet_payment’ meta in the order.

    How can I fix this issue please?

    Thanks a lot for any help.

    Regards Milan from Czech Republic

    • This topic was modified 2 years, 3 months ago by minovec.
    • This topic was modified 2 years, 3 months ago by minovec.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter minovec

    (@minovec)

    Please help me, this is going to by critical, I am using this plugin in the production a long time….

    Plugin Author Subrata Mal

    (@subratamal)

    @minovec

    Please use updated code.

    add_action('woocommerce_checkout_order_processed', 'process_woo_wallet_partial_payment', 40, 1);
    
    function process_woo_wallet_partial_payment($order_id) {
        $order = wc_get_order($order_id);
        $partial_payment_amount = get_order_partial_payment_amount( $order_id );
        if ($partial_payment_amount && !get_post_meta($order_id, '_partial_pay_through_wallet_compleate', true)) {
            $transaction_id = woo_wallet()->wallet->debit($order->get_customer_id(), $partial_payment_amount, __('For order payment #', 'woo-wallet') . $order->get_id());
            if ($transaction_id) {
                $order->add_order_note(sprintf(__('%s paid through wallet', 'woo-wallet'), wc_price($partial_payment_amount)));
                update_wallet_transaction_meta($transaction_id, '_partial_payment', true, $order->get_id());
                update_post_meta($order_id, '_partial_pay_through_wallet_compleate', $transaction_id);
            }
        }
    }

    Thank you.

    Thread Starter minovec

    (@minovec)

    Hello,

    thank you very much, it’s working now.

    I love this excelent plugin and your support.

    Regards

    Milan

    Plugin Author Subrata Mal

    (@subratamal)

    @minovec

    Thanks, Could you please consider posting a review for our plugin? In addition to providing feedback, reviews can help other users to know who we are and what our plugin does.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Partial payments – no debit in wallet’ is closed to new replies.