本文整理汇总了PHP中unknown::get_items方法的典型用法代码示例。如果您正苦于以下问题:PHP unknown::get_items方法的具体用法?PHP unknown::get_items怎么用?PHP unknown::get_items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unknown
的用法示例。
在下文中一共展示了unknown::get_items方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_vendor_dues_from_order
/**
*
*
* @param unknown $order
* @param unknown $group (optional)
*
* @return unknown
*/
public function get_vendor_dues_from_order($order, $group = true)
{
global $woocommerce;
$give_tax = Product_Vendor::$pv_options->get_option('give_tax');
$receiver = array();
$shipping_given = 0;
$tax_given = 0;
foreach ($order->get_items() as $key => $product) {
$product_id = !empty($product['variation_id']) ? $product['variation_id'] : $product['product_id'];
$author = PV_Vendors::get_vendor_from_product($product_id);
$is_vendor = PV_Vendors::is_vendor($author);
$commission = $is_vendor ? PV_Commission::calculate_commission($product['line_subtotal'], $product_id, $order) : 0;
$tax = !empty($product['line_tax']) ? (double) $product['line_tax'] : 0;
$shipping = PV_Shipping::get_shipping_due($order->id, $product, $author);
if ($is_vendor) {
$shipping_given += $shipping;
$tax_given += $give_tax ? $tax : 0;
$give = 0;
$give += !empty($receiver[$author]['total']) ? $receiver[$author]['total'] : 0;
$give += $shipping;
$give += $commission;
$give += $give_tax ? $tax : 0;
if ($group) {
$receiver[$author] = array('vendor_id' => (int) $author, 'commission' => !empty($receiver[$author]['commission']) ? $receiver[$author]['commission'] + $commission : $commission, 'shipping' => !empty($receiver[$author]['shipping']) ? $receiver[$author]['shipping'] + $shipping : $shipping, 'tax' => $give_tax ? !empty($receiver[$author]['tax']) ? $receiver[$author]['tax'] + $tax : $tax : 0, 'qty' => !empty($receiver[$author]['qty']) ? $receiver[$author]['qty'] + $product['qty'] : $product['qty'], 'total' => $give);
} else {
$receiver[$author][$product_id] = array('vendor_id' => (int) $author, 'product_id' => $product_id, 'commission' => $commission, 'shipping' => $shipping, 'tax' => $give_tax ? $tax : 0, 'qty' => $product['qty'], 'total' => $shipping + $commission + ($give_tax ? $tax : 0));
}
}
$admin_comm = $product['line_subtotal'] - $commission;
if ($group) {
$receiver[1] = array('vendor_id' => 1, 'qty' => !empty($receiver[1]['qty']) ? $receiver[1]['qty'] + $product['qty'] : $product['qty'], 'commission' => !empty($receiver[1]['commission']) ? $receiver[1]['commission'] + $admin_comm : $admin_comm, 'total' => !empty($receiver[1]) ? $receiver[1]['total'] + $admin_comm : $admin_comm);
} else {
$receiver[1][$product_id] = array('vendor_id' => 1, 'product_id' => $product_id, 'commission' => $admin_comm, 'shipping' => 0, 'tax' => 0, 'qty' => $product['qty'], 'total' => $admin_comm);
}
}
// Add remainders on end to admin
$discount = $order->get_total_discount();
$shipping = $order->order_shipping - $shipping_given;
$tax = $order->order_tax + $order->order_shipping_tax - $tax_given;
$total = $tax + $shipping - $discount;
if ($group) {
$receiver[1]['commission'] = $receiver[1]['commission'] - $discount;
$receiver[1]['shipping'] = $shipping;
$receiver[1]['tax'] = $tax;
$receiver[1]['total'] += $total;
} else {
$receiver[1][$product_id]['commission'] = $receiver[1][$product_id]['commission'] - $discount;
$receiver[1][$product_id]['shipping'] = $order->order_shipping - $shipping_given;
$receiver[1][$product_id]['tax'] = $tax;
$receiver[1][$product_id]['total'] += $total;
}
// Reset the array keys
// $receivers = array_values( $receiver );
return $receiver;
}
示例2: get_vendor_dues_from_order
/**
*
*
* @param unknown $order
* @param unknown $group (optional)
*
* @return unknown
*/
public static function get_vendor_dues_from_order($order, $group = true)
{
global $woocommerce;
$give_tax = WC_Vendors::$pv_options->get_option('give_tax');
$give_shipping = WC_Vendors::$pv_options->get_option('give_shipping');
$receiver = array();
$shipping_given = 0;
$tax_given = 0;
WCV_Shipping::$pps_shipping_costs = array();
foreach ($order->get_items() as $key => $product) {
$product_id = !empty($product['variation_id']) ? $product['variation_id'] : $product['product_id'];
$author = WCV_Vendors::get_vendor_from_product($product_id);
$give_tax_override = get_user_meta($author, 'wcv_give_vendor_tax', true);
$give_shipping_override = get_user_meta($author, 'wcv_give_vendor_shipping', true);
$is_vendor = WCV_Vendors::is_vendor($author);
$commission = $is_vendor ? WCV_Commission::calculate_commission($product['line_subtotal'], $product_id, $order) : 0;
$tax = !empty($product['line_tax']) ? (double) $product['line_tax'] : 0;
// Check if shipping is enabled
if (get_option('woocommerce_calc_shipping') === 'no') {
$shipping = 0;
$shipping_tax = 0;
} else {
$shipping_costs = WCV_Shipping::get_shipping_due($order->id, $product, $author);
$shipping = $shipping_costs['amount'];
$shipping_tax = $shipping_costs['tax'];
}
// Add line item tax and shipping taxes together
$total_tax = (double) $tax + (double) $shipping_tax;
// Tax override on a per vendor basis
if ($give_tax_override) {
$give_tax = true;
}
// Shipping override
if ($give_shipping_override) {
$give_shipping = true;
}
if ($is_vendor) {
$shipping_given += $give_shipping ? $shipping : 0;
$tax_given += $give_tax ? $total_tax : 0;
$give = 0;
$give += !empty($receiver[$author]['total']) ? $receiver[$author]['total'] : 0;
$give += $give_shipping ? $shipping : 0;
$give += $commission;
$give += $give_tax ? $total_tax : 0;
if ($group) {
$receiver[$author] = array('vendor_id' => (int) $author, 'commission' => !empty($receiver[$author]['commission']) ? $receiver[$author]['commission'] + $commission : $commission, 'shipping' => $give_shipping ? !empty($receiver[$author]['shipping']) ? $receiver[$author]['shipping'] + $shipping : $shipping : 0, 'tax' => $give_tax ? !empty($receiver[$author]['tax']) ? $receiver[$author]['tax'] + $total_tax : $total_tax : 0, 'qty' => !empty($receiver[$author]['qty']) ? $receiver[$author]['qty'] + $product['qty'] : $product['qty'], 'total' => $give);
} else {
$receiver[$author][$key] = array('vendor_id' => (int) $author, 'product_id' => $product_id, 'commission' => $commission, 'shipping' => $give_shipping ? $shipping : 0, 'tax' => $give_tax ? $total_tax : 0, 'qty' => $product['qty'], 'total' => ($give_shipping ? $shipping : 0) + $commission + ($give_tax ? $total_tax : 0));
}
}
$admin_comm = $product['line_subtotal'] - $commission;
if ($group) {
$receiver[1] = array('vendor_id' => 1, 'qty' => !empty($receiver[1]['qty']) ? $receiver[1]['qty'] + $product['qty'] : $product['qty'], 'commission' => !empty($receiver[1]['commission']) ? $receiver[1]['commission'] + $admin_comm : $admin_comm, 'total' => !empty($receiver[1]) ? $receiver[1]['total'] + $admin_comm : $admin_comm);
} else {
$receiver[1][$key] = array('vendor_id' => 1, 'product_id' => $product_id, 'commission' => $admin_comm, 'shipping' => 0, 'tax' => 0, 'qty' => $product['qty'], 'total' => $admin_comm);
}
}
// Add remainders on end to admin
$discount = $order->get_total_discount();
$shipping = $order->order_shipping - $shipping_given;
$tax = round($order->order_tax + $order->order_shipping_tax - $tax_given, 2);
$total = $tax + $shipping - $discount;
if ($group) {
$receiver[1]['commission'] = $receiver[1]['commission'] - $discount;
$receiver[1]['shipping'] = $shipping;
$receiver[1]['tax'] = $tax;
$receiver[1]['total'] += $total;
} else {
$receiver[1][$key]['commission'] = $receiver[1][$key]['commission'] - $discount;
$receiver[1][$key]['shipping'] = $order->order_shipping - $shipping_given;
$receiver[1][$key]['tax'] = $tax;
$receiver[1][$key]['total'] += $total;
}
// Reset the array keys
// $receivers = array_values( $receiver );
return $receiver;
}
示例3: get_vendors
/**
*
*
* @param unknown $order
*
* @return unknown
*/
public function get_vendors($order)
{
$items = $order->get_items();
$vendors = array();
foreach ($items as $key => $product) {
if (empty($product['product_id'])) {
continue;
}
$author = WCV_Vendors::get_vendor_from_product($product['product_id']);
// Only store the vendor authors
if (!WCV_Vendors::is_vendor($author)) {
unset($items[$key]);
continue;
}
$vendors[$author] = get_userdata($author)->user_email;
}
return $vendors;
}