本文整理汇总了PHP中WCV_Vendors::get_vendor_from_product方法的典型用法代码示例。如果您正苦于以下问题:PHP WCV_Vendors::get_vendor_from_product方法的具体用法?PHP WCV_Vendors::get_vendor_from_product怎么用?PHP WCV_Vendors::get_vendor_from_product使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WCV_Vendors
的用法示例。
在下文中一共展示了WCV_Vendors::get_vendor_from_product方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: new_comment
/**
* Submit a comment for an order
*
* @param object $orders
*
* @return unknown
*/
public static function new_comment($orders)
{
global $woocommerce;
$user = wp_get_current_user();
$user = $user->ID;
// Security
if (!wp_verify_nonce($_POST['_wpnonce'], 'add-comment')) {
return false;
}
// Check if this product belongs to the vendor submitting the comment
$product_id = (int) $_POST['product_id'];
$author = WCV_Vendors::get_vendor_from_product($product_id);
if ($author != $user) {
return false;
}
// Find the order belonging to this comment
foreach ($orders as $order) {
if ($order->order_id == $_POST['order_id']) {
$found_order = $order;
break;
}
}
// No order was found
if (empty($found_order)) {
return false;
}
// Don't submit empty comments
if (empty($_POST['comment_text'])) {
if (function_exists('wc_add_error')) {
wc_add_error(__('You\'ve left the comment field empty!', 'wcvendors'));
} else {
$woocommerce->add_error(__('You\'ve left the comment field empty!', 'wcvendors'));
}
return false;
}
// Only submit if the order has the product belonging to this vendor
$found_order = new WC_Order($found_order->order_id);
$valid_order = false;
foreach ($found_order->get_items() as $item) {
if ($item['product_id'] == $product_id) {
$valid_order = true;
break;
}
}
if ($valid_order) {
$comment = esc_textarea($_POST['comment_text']);
add_filter('woocommerce_new_order_note_data', array(__CLASS__, 'filter_comment'), 10, 2);
$found_order->add_order_note($comment, 1);
remove_filter('woocommerce_new_order_note_data', array(__CLASS__, 'filter_comment'), 10, 2);
if (function_exists('wc_add_message')) {
wc_add_message(__('Success. The customer has been notified of your comment.', 'wcvendors'));
} else {
$woocommerce->add_message(__('Success. The customer has been notified of your comment.', 'wcvendors'));
}
}
}
示例2: check_items
/**
*
*
* @param unknown $items
* @param unknown $order
*
* @return unknown
*/
public function check_items($items, $order)
{
foreach ($items as $key => $product) {
if (empty($product['product_id'])) {
unset($items[$key]);
continue;
}
$author = WCV_Vendors::get_vendor_from_product($product['product_id']);
if ($this->current_vendor != $author) {
unset($items[$key]);
continue;
}
}
return $items;
}
示例3: mango_wpvendors_product_seller_name
function mango_wpvendors_product_seller_name()
{
global $mango_settings;
$product_id = get_the_ID();
$author = WCV_Vendors::get_vendor_from_product($product_id);
$vendor_display_name = WC_Vendors::$pv_options->get_option('vendor_display_name');
switch ($vendor_display_name) {
case 'display_name':
$vendor = get_userdata($author);
$vendor_name = $vendor->display_name;
break;
case 'user_login':
$vendor = get_userdata($author);
$vendor_name = $vendor->user_login;
break;
default:
$vendor_name = WCV_Vendors::get_vendor_shop_name($author);
break;
}
$sold_by = WCV_Vendors::is_vendor($author) ? sprintf('<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page($author), $vendor_name) : get_bloginfo('name');
if ($mango_settings['mango_wcvendors_shop_soldby']) {
echo '<p class="product-seller-name">' . apply_filters('wcvendors_sold_by_in_loop', __('By', 'mango')) . ' <span>' . $sold_by . '</span> </p>';
}
}
示例4: 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;
}
示例5: wpautop
</h2>
<?php
}
?>
<div class="wcv_shop_description">
<?php
echo wpautop($shop_description);
?>
</div>
<?php
if (of_get_option('tokopress_wcvendors_shop_profile') != 'no') {
?>
<?php
$author = WCV_Vendors::get_vendor_from_product(get_the_ID());
$user = get_userdata($author);
?>
<p class="user-social">
<?php
if ($user->facebook_url) {
?>
<span class="user-facebook"><a rel="nofollow" href="<?php
echo esc_url($user->facebook_url);
?>
"><i class="fa fa-facebook"></i></a></span>
<?php
}
?>
<?php
示例6: urldecode
}
$vendor_shop = urldecode(get_query_var('vendor_shop'));
if (!$vendor_shop) {
return;
}
$vendor_id = WCV_Vendors::get_vendor_id($vendor_shop);
if (!$vendor_id) {
return;
}
$vendor_avatar = of_get_option('tokopress_wcvendors_shop_avatar') != 'no' ? true : false;
$vendor_profile = of_get_option('tokopress_wcvendors_shop_profile') != 'no' ? true : false;
} else {
if (of_get_option('tokopress_wcvendors_product_description') != 'yes') {
return;
}
$vendor_id = WCV_Vendors::get_vendor_from_product(get_the_ID());
if (!$vendor_id) {
return;
}
$vendor_avatar = of_get_option('tokopress_wcvendors_product_avatar') == 'yes' ? true : false;
$vendor_profile = of_get_option('tokopress_wcvendors_product_profile') != 'no' ? true : false;
}
$vendor = get_userdata($vendor_id);
if (!$vendor) {
return;
}
$vendor_display_name = WC_Vendors::$pv_options->get_option('vendor_display_name');
switch ($vendor_display_name) {
case 'display_name':
$vendor_name = $vendor->display_name;
break;
示例7: tokopress_wcvendors_seller_info_tab_panel
function tokopress_wcvendors_seller_info_tab_panel()
{
$product_id = get_the_ID();
$author = WCV_Vendors::get_vendor_from_product($product_id);
$shop_name = WCV_Vendors::get_vendor_shop_name($author);
echo '<h2>' . $shop_name . '</h2>';
global $post;
$seller_info = get_user_meta($post->post_author, 'pv_seller_info', true);
$has_html = get_user_meta($post->post_author, 'pv_shop_html_enabled', true);
$global_html = WC_Vendors::$pv_options->get_option('shop_html_enabled');
$seller_info = do_shortcode($seller_info);
echo '<div class="pv_seller_info">';
echo $global_html || $has_html ? wpautop(wptexturize(wp_kses_post($seller_info))) : sanitize_text_field($seller_info);
echo '<p>';
echo '<a href="' . WCV_Vendors::get_vendor_shop_page($author) . '" class="button alt">' . sprintf(__('Visit "%s" Shop', 'tokopress'), $shop_name) . '</a>';
echo '<a href="' . get_author_posts_url($author) . '#contact-form" class="button alt">' . __('Contact this seller', 'tokopress') . '</a>';
echo '</p>';
echo '</div>';
}
示例8: template_loop_sold_by
public static function template_loop_sold_by($product_id)
{
$vendor_id = WCV_Vendors::get_vendor_from_product($product_id);
$sold_by_label = WC_Vendors::$pv_options->get_option('sold_by_label');
$sold_by = WCV_Vendors::is_vendor($vendor_id) ? sprintf('<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page($vendor_id), WCV_Vendors::get_vendor_sold_by($vendor_id)) : get_bloginfo('name');
echo '<small class="wcvendors_sold_by_in_loop">' . apply_filters('wcvendors_sold_by_in_loop', $sold_by_label) . ' ' . $sold_by . '</small> <br />';
}
示例9: get_commission_rate
/**
* Product's commission rate in percentage form
*
* Eg: 50 for 50%
*
* @param int $product_id
*
* @return float
*/
public static function get_commission_rate($product_id)
{
$commission = 0;
$parent = get_post_ancestors($product_id);
if ($parent) {
$product_id = $parent[0];
}
$vendor_id = WCV_Vendors::get_vendor_from_product($product_id);
$product_commission = get_post_meta($product_id, 'pv_commission_rate', true);
$vendor_commission = WCV_Vendors::get_default_commission($vendor_id);
$default_commission = WC_Vendors::$pv_options->get_option('default_commission');
if ($product_commission != '' && $product_commission !== false) {
$commission = $product_commission;
} else {
if ($vendor_commission != '' && $vendor_commission !== false) {
$commission = $vendor_commission;
} else {
if ($default_commission != '' && $default_commission !== false) {
$commission = $default_commission;
}
}
}
return apply_filters('wcv_commission_rate_percent', $commission, $product_id);
}
示例10: check_items
/**
*
*
* @param unknown $items
* @param unknown $order
*
* @return unknown
*/
function check_items($items, $order)
{
foreach ($items as $key => $product) {
// If this is a line item
if ($product['type'] == 'line_item') {
$author = WCV_Vendors::get_vendor_from_product($product['product_id']);
if ($this->current_vendor != $author) {
unset($items[$key]);
continue;
} else {
$commission_due = WCV_Commission::calculate_commission($product['line_subtotal'], $product['product_id'], $order);
$items[$key]['line_subtotal'] = $commission_due;
$items[$key]['line_total'] = $commission_due;
// Don't display tax if give tax is not enabled.
// if ( !WC_Vendors::$pv_options->get_option( 'give_tax' ) ) {
// unset($items[ $key ][ 'line_tax' ]) ;
// }
}
}
}
return $items;
}
示例11: template_loop_sold_by
public function template_loop_sold_by($product_id)
{
$author = WCV_Vendors::get_vendor_from_product($product_id);
$sold_by = WCV_Vendors::is_vendor($author) ? sprintf('<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page($author), WCV_Vendors::get_vendor_shop_name($author)) : get_bloginfo('name');
echo '<small>' . apply_filters('wcvendors_sold_by_in_loop', __('Sold by: ', 'wcvendors')) . $sold_by . '</small> <br />';
}
示例12: check_items
/**
*
*
* @param unknown $items
* @param unknown $order
*
* @return unknown
*/
function check_items($items, $order)
{
$settings = get_option('woocommerce_vendor_new_order_settings');
foreach ($items as $key => $product) {
// If this is a line item
if ($product['type'] == 'line_item') {
$author = WCV_Vendors::get_vendor_from_product($product['product_id']);
if ($this->current_vendor != $author) {
unset($items[$key]);
continue;
} else {
// If display commission is ticked show this otherwise show the full price.
if ('yes' == $settings['commission_display']) {
$commission_due = WCV_Commission::calculate_commission($product['line_subtotal'], $product['product_id'], $order, $product['qty']);
$items[$key]['line_subtotal'] = $commission_due;
$items[$key]['line_total'] = $commission_due;
// Don't display tax if give tax is not enabled.
if (!WC_Vendors::$pv_options->get_option('give_tax')) {
unset($items[$key]['line_tax']);
}
}
}
}
}
return $items;
}
示例13: get_vendor_id
private function get_vendor_id($product_id)
{
$author = WCV_Vendors::get_vendor_from_product($product_id);
return $author;
}
示例14: check_items
/**
*
*
* @param unknown $items
* @param unknown $order
*
* @return unknown
*/
function check_items($items, $order)
{
foreach ($items as $key => $product) {
// If this is a line item
if ($product['type'] == 'line_item') {
$author = WCV_Vendors::get_vendor_from_product($product['product_id']);
if ($this->current_vendor != $author) {
unset($items[$key]);
continue;
} else {
$commission_due = WCV_Commission::calculate_commission($product['line_subtotal'], $product['product_id'], $order);
$items[$key]['line_subtotal'] = $commission_due;
$items[$key]['line_total'] = $commission_due;
unset($items[$key]['line_tax']);
}
}
}
return $items;
}
示例15: mango_wc_vendor_header
function mango_wc_vendor_header()
{
global $mango_settings, $post, $wp_query, $vendor_shop;
$vendor_id = WCV_Vendors::get_vendor_id($vendor_shop);
$shop_name = get_user_meta($vendor_id, 'pv_shop_name', true);
$description = do_shortcode(get_user_meta($vendor_id, 'pv_shop_description', true));
if ($vendor_shop) {
if ($mango_settings['mango_wcvendors_shop_description']) {
?>
<?php
$product_id = get_the_ID();
$author = WCV_Vendors::get_vendor_from_product($product_id);
$link = WCV_Vendors::get_vendor_shop_page($author);
$author = WCV_Vendors::get_vendor_from_product(get_the_ID());
$user = get_userdata($author);
?>
<?php
$r = get_user_meta($user->ID, 'picture', true);
$r = $r['url'];
if ($r) {
?>
<div class="vendor-profile-bg" style="background:url('<?php
echo $r;
?>
') ;background-size:cover">
<?php
} else {
?>
<div class="vendor-profile-bg">
<?php
}
?>
<div class="overlay-vendor-effect">
<?php
if ($mango_settings['mango_wcvendors_shop_avatar']) {
?>
<div class="vendor_userimg">
<div class="profile-img">
<a href="<?php
echo $link;
?>
"> <?php
echo get_avatar($vendor_id, 80);
?>
</a>
</div>
</div>
<?php
}
?>
<h1><a href="<?php
echo $link;
?>
"><?php
echo $shop_name;
?>
</a></h1>
<div class="custom_shop_description">
<?php
echo wpautop($description);
?>
</div>
<?php
$author = WCV_Vendors::get_vendor_from_product(get_the_ID());
$user = get_userdata($author);
if ($mango_settings['mango_wcvendors_shop_profile']) {
?>
<?php
if ($mango_settings['mango_wcvendors_phone']) {
if ($user->phone_number) {
?>
<span class="vendorcustom-mail"><i class="fa fa-phone aligmentvendor"></i> <?php
echo $user->phone_number;
?>
</span>
<?php
}
}
?>
<?php
if ($mango_settings['mango_wcvendors_email']) {
if ($user->user_email) {
?>
<span class="vendorcustom-mail"><i class="fa fa-envelope aligmentvendor"></i> <?php
echo $user->user_email;
?>
</span>
<?php
}
}
?>
<?php
if ($mango_settings['mango_wcvendors_url']) {
if ($user->user_url) {
//.........这里部分代码省略.........