本文整理匯總了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));
}
}
}