本文整理汇总了PHP中WCV_Vendors::create_vendor_order方法的典型用法代码示例。如果您正苦于以下问题:PHP WCV_Vendors::create_vendor_order方法的具体用法?PHP WCV_Vendors::create_vendor_order怎么用?PHP WCV_Vendors::create_vendor_order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WCV_Vendors
的用法示例。
在下文中一共展示了WCV_Vendors::create_vendor_order方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_child_orders
/**
* Split order into vendor orders (when applicable) after checkout
*
* @since
* @param int $order_id
* @return void
*/
public static function create_child_orders($order_id)
{
$order = wc_get_order($order_id);
$items = $order->get_items();
$vendor_items = array();
foreach ($items as $item_id => $item) {
if (isset($item['product_id']) && $item['product_id'] !== 0) {
// check if product is from vendor
$product_author = get_post_field('post_author', $item['product_id']);
if (WCV_Vendors::is_vendor($product_author)) {
$vendor_items[$product_author][$item_id] = array('item_id' => $item_id, 'qty' => $item['qty'], 'total' => $item['line_total'], 'subtotal' => $item['line_subtotal'], 'tax' => $item['line_tax'], 'subtotal_tax' => $item['line_subtotal_tax'], 'tax_data' => maybe_unserialize($item['line_tax_data']), 'commission' => WCV_Commission::calculate_commission($item['line_subtotal'], $item['product_id'], $order, $item['qty']));
}
}
}
foreach ($vendor_items as $vendor_id => $items) {
if (!empty($items)) {
$vendor_order = WCV_Vendors::create_vendor_order(array('order_id' => $order_id, 'vendor_id' => $vendor_id, 'line_items' => $items));
}
}
}