i'm running a woocommerce wordpress store and i've integrated a virtual wallet add-on called "terawallet aka woo-wallet". this add-on gives each user on the site the option to top-up their virtual wallet, withdraw funds or use it as a payment method during checkout.
i would like to create a function/hook that automatically tops-up the product author wallet(user who posted the product post) when a product is purchased. I'm using a marketplace plugin that sets commission for each vendor/seller and after purchase, admin gets a commision and seller gets the remainder (total_seller_amount)
so e.g USER 1=seller and user 2=buyer when buyer purchases a product, the seller virtual account should automatically be topped up with the amount remaining after admin commission when product order is completed(processed). so if the buyer purchases 4 products that belong to 4 different product authors, each author should be credited accordingly to the product linked to their user ID.
the woo-wallet class is called 'woo_wallet_wallet'
below is the function that credits users wallet:
/**
* Create wallet payment credit transaction
* @param int $user_id
* @param float $amount
* @param string $details
* @return int transaction id
*/
public function credit( $user_id = '', $amount = 0, $details = '' ) {
$this->set_user_id( $user_id );
return $this->recode_transaction( $amount, 'credit', $details );
}
I tried the following code:
$wallet = woo_wallet_wallet ();
$wallet ->credit($product_user_id,, (total_seller_amount), ‘credit’,)