based off this link Payfast split payments which appears to work. How does one run a multi vendor woocommerce store and then split the payment to the associated merchant based on the product purchased?
Asked
Active
Viewed 125 times
0
-
Hello and welcome! Please try to ask your question more precisely. Do you have some code or where is your problem? – Chrostip Schaejn Jun 17 '22 at 15:34
-
basically we are using the woocommerce multi vendor plugin which allows multiple vendors to sell products on single platform, we then utilise a payment gateway called PayFast. Payfast have a feature called "split payments" where you specify in the array the merchant id of the woocommerce store owner to split payment to. this works perfectly fine, however we want to dynamically split the payments in the array whereby the array would look up who the vendor is that owns the product being sold, currently we can only statically specify one merchant id to split payment to. i hope i explained it well – Tyron van Greunen Jun 22 '22 at 16:59
1 Answers
0
Typically, this information is stored at the order item level. So, you need to loop through the items, get the vendor id and do your splitting payment action. E.g. like this on the admin order page:
global $order;
$items = $order->get_items();
foreach ( $items as $item_key => $item ) {
$vendor_id = wc_get_order_item_meta( $item_key, '_vendor_id', true );
// Now get the merchant id with $vendor_id (=user id) and do split payment.
// You can also create an array with $merchant_id => $item->get_subtotal()
// and do the split payment after the loop.
}
The meta key "_vendor_id" depends on your plugin - I used WCMP (Multivendor Marketplace Solution for WooCommerce – WC Marketplace). You may need to look it up in your database how the field is called.

Chrostip Schaejn
- 2,347
- 1
- 6
- 13