基于此链接Payfast split payment,这似乎有效。如何运营多供应商 woocommerce 商店,然后根据购买的产品将付款分配给相关商家?
通常,此信息存储在订单项目级别。因此,您需要循环遍历项目,获取供应商 ID 并执行拆分付款操作。 例如。在管理订单页面上就像这样:
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.
}
元键“_vendor_id”取决于您的插件 - 我使用了 WCMP(WooCommerce 的多供应商市场解决方案 - WC Marketplace)。您可能需要在数据库中查找该字段的名称。