本文整理汇总了PHP中WCV_Vendors::count_due_by_vendor方法的典型用法代码示例。如果您正苦于以下问题:PHP WCV_Vendors::count_due_by_vendor方法的具体用法?PHP WCV_Vendors::count_due_by_vendor怎么用?PHP WCV_Vendors::count_due_by_vendor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WCV_Vendors
的用法示例。
在下文中一共展示了WCV_Vendors::count_due_by_vendor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log_commission_due
/**
* Store all commission due for an order
*
* @return bool
*
* @param int $order_id
*/
public static function log_commission_due($order_id)
{
global $woocommerce;
$order = new WC_Order($order_id);
$dues = WCV_Vendors::get_vendor_dues_from_order($order, false);
foreach ($dues as $vendor_id => $details) {
// Only process vendor commission
if (!WCV_Vendors::is_vendor($vendor_id)) {
continue;
}
// See if they currently have an amount due
$due = WCV_Vendors::count_due_by_vendor($vendor_id, $order_id);
if ($due > 0) {
continue;
}
// Get the dues in an easy format for inserting to our table
$insert_due = array();
foreach ($details as $key => $detail) {
$product_id = $detail['product_id'];
$insert_due[$product_id] = array('order_id' => $order_id, 'vendor_id' => $vendor_id, 'product_id' => $product_id, 'total_due' => !empty($insert_due[$product_id]['total_due']) ? $detail['commission'] + $insert_due[$product_id]['total_due'] : $detail['commission'], 'total_shipping' => !empty($insert_due[$product_id]['total_shipping']) ? $detail['shipping'] + $insert_due[$product_id]['total_shipping'] : $detail['shipping'], 'tax' => !empty($insert_due[$product_id]['tax']) ? $detail['tax'] + $insert_due[$product_id]['tax'] : $detail['tax'], 'qty' => !empty($insert_due[$product_id]['qty']) ? $detail['qty'] + $insert_due[$product_id]['qty'] : $detail['qty'], 'time' => $order->order_date);
}
if (!empty($insert_due)) {
WCV_Commission::insert_new_commission(array_values($insert_due));
}
}
}