本文整理汇总了PHP中WCV_Vendors::is_vendor方法的典型用法代码示例。如果您正苦于以下问题:PHP WCV_Vendors::is_vendor方法的具体用法?PHP WCV_Vendors::is_vendor怎么用?PHP WCV_Vendors::is_vendor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WCV_Vendors
的用法示例。
在下文中一共展示了WCV_Vendors::is_vendor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*/
function __construct()
{
if (!is_admin()) {
return;
}
add_action('edit_user_profile', array($this, 'show_extra_profile_fields'));
add_action('edit_user_profile_update', array($this, 'save_extra_profile_fields'));
add_filter('add_menu_classes', array($this, 'show_pending_number'));
// Disabling non-vendor related items on the admin screens
if (WCV_Vendors::is_vendor(get_current_user_id())) {
add_filter('woocommerce_csv_product_role', array($this, 'csv_import_suite_compatibility'));
add_filter('woocommerce_csv_product_export_args', array($this, 'csv_import_suite_compatibility_export'));
// Admin page lockdown
remove_action('admin_init', 'woocommerce_prevent_admin_access');
add_action('admin_init', array($this, 'prevent_admin_access'));
add_filter('woocommerce_prevent_admin_access', array($this, 'deny_admin_access'));
// WC > Product page fixes
add_action('load-post-new.php', array($this, 'confirm_access_to_add'));
add_action('load-edit.php', array($this, 'edit_nonvendors'));
add_filter('views_edit-product', array($this, 'hide_nonvendor_links'));
// Filter user attachments so they only see their own attachements
add_action('ajax_query_attachments_args', array($this, 'show_user_attachment_ajax'));
add_filter('parse_query', array($this, 'show_user_attachment_page'));
add_action('admin_menu', array($this, 'remove_menu_page'), 99);
add_action('add_meta_boxes', array($this, 'remove_meta_boxes'), 99);
add_filter('product_type_selector', array($this, 'filter_product_types'), 99, 2);
add_filter('product_type_options', array($this, 'filter_product_type_options'), 99);
add_filter('woocommerce_duplicate_product_capability', array($this, 'add_duplicate_capability'));
// WC > Product featured
$product_misc = (array) WC_Vendors::$pv_options->get_option('hide_product_misc');
if (isset($product_misc['featured'])) {
add_filter('manage_product_posts_columns', array($this, 'manage_product_columns'), 99);
}
}
}
示例2: 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));
}
}
}
示例3: show_vendor_in_email
/**
*
*
* @param unknown $name
* @param unknown $_product
*
* @return unknown
*/
function show_vendor_in_email($name, $_product)
{
$product = get_post($_product->id);
$sold_by = WCV_Vendors::is_vendor($product->post_author) ? sprintf('<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page($product->post_author), WCV_Vendors::get_vendor_sold_by($product->post_author)) : get_bloginfo('name');
$name .= '<small class="wcvendors_sold_by_in_email"><br />' . apply_filters('wcvendors_sold_by_in_email', __('Sold by: ', 'wcvendors')) . $sold_by . '</small><br />';
return $name;
}
示例4: sold_by_meta
/**
* Single product meta
*/
public static function sold_by_meta()
{
$vendor_id = get_the_author_meta('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" class="wcvendors_cart_sold_by_meta">%s</a>', WCV_Vendors::get_vendor_shop_page($vendor_id), WCV_Vendors::get_vendor_sold_by($vendor_id)) : get_bloginfo('name');
echo apply_filters('wcvendors_cart_sold_by_meta', $sold_by_label) . $sold_by . '<br/>';
}
示例5: trigger
/**
* trigger function.
*
* @access public
* @return void
*
* @param unknown $order_id
*/
function trigger($post_id, $post)
{
if (!WCV_Vendors::is_vendor($post->post_author)) {
return;
}
$this->find[] = '{product_name}';
$this->product_name = $post->post_title;
$this->replace[] = $this->product_name;
$this->find[] = '{vendor_name}';
$this->vendor_name = WCV_Vendors::get_vendor_shop_name($post->post_author);
$this->replace[] = $this->vendor_name;
$this->post_id = $post->ID;
$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
}
示例6: display_product_orders
/**
* Use views to display the Orders page
*
* @return html
*/
public function display_product_orders()
{
if (!WCV_Vendors::is_vendor(get_current_user_id())) {
ob_start();
wc_get_template('denied.php', array(), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/');
return ob_get_clean();
}
if (empty($_GET['orders_for_product'])) {
return __('You haven\'t selected a product\'s orders to view! Please go back to the Vendor Dashboard and click Show Orders on the product you\'d like to view.', 'wcvendors');
}
if (!$this->orders) {
return __('No orders.', 'wcvendors');
}
if (!empty($_POST['submit_comment'])) {
require_once wcv_plugin_dir . 'classes/front/orders/class-submit-comment.php';
WCV_Submit_Comment::new_comment($this->orders);
}
if (isset($_POST['mark_shipped'])) {
$order_id = (int) $_POST['order_id'];
$product_id = (int) $_POST['product_id'];
exit;
}
$headers = WCV_Orders::get_headers();
$all = WCV_Orders::format_order_details($this->orders, $this->product_id);
wp_enqueue_style('pv_frontend_style', wcv_assets_url . 'css/wcv-frontend.css');
wp_enqueue_script('pv_frontend_script', wcv_assets_url . 'js/front-orders.js');
$providers = array();
$provider_array = array();
// WC Shipment Tracking Providers
if (class_exists('WC_Shipment_Tracking')) {
$WC_Shipment_Tracking = new WC_Shipment_Tracking();
$providers = method_exists($WC_Shipment_Tracking, 'get_providers') ? $WC_Shipment_Tracking->get_providers() : $WC_Shipment_Tracking->providers;
$provider_array = array();
foreach ($providers as $all_providers) {
foreach ($all_providers as $provider => $format) {
$provider_array[sanitize_title($provider)] = urlencode($format);
}
}
}
ob_start();
// Show the Export CSV button
if ($this->can_export_csv) {
wc_get_template('csv-export.php', array(), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/');
}
wc_get_template('orders.php', array('headers' => $headers, 'body' => $all['body'], 'items' => $all['items'], 'product_id' => $all['product_id'], 'providers' => $providers, 'provider_array' => $provider_array), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/');
return ob_get_clean();
}
示例7: trigger
/**
* trigger function.
*
* @access public
* @return void
*
* @param unknown $order_id
*/
function trigger($new_status, $old_status, $post)
{
// Ensure this is only firing on products
if (!in_array($post->post_type, array('product', 'product_variation'))) {
return;
}
// Ensure that the post author is a vendor
if (!WCV_Vendors::is_vendor($post->post_author)) {
return;
}
if (!$this->is_enabled()) {
return;
}
$this->find[] = '{product_name}';
$this->product_name = $post->post_title;
$this->replace[] = $this->product_name;
$this->find[] = '{vendor_name}';
$this->vendor_name = WCV_Vendors::get_vendor_shop_name($post->post_author);
$this->replace[] = $this->vendor_name;
$this->post_id = $post->ID;
$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
}
示例8: display_product_orders
/**
* Use views to display the Orders page
*
* @return html
*/
public function display_product_orders()
{
if (!WCV_Vendors::is_vendor(get_current_user_id())) {
ob_start();
wc_get_template('denied.php', array(), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/');
return ob_get_clean();
}
if (empty($_GET['orders_for_product'])) {
return __('You haven\'t selected a product\'s orders to view! Please go back to the Vendor Dashboard and click Show Orders on the product you\'d like to view.', 'wcvendors');
}
if (!$this->orders) {
return __('No orders.', 'wcvendors');
}
if (!empty($_POST['submit_comment'])) {
require_once wcv_plugin_dir . 'classes/front/orders/class-submit-comment.php';
WCV_Submit_Comment::new_comment($this->orders);
}
if (isset($_POST['mark_shipped'])) {
$order_id = (int) $_POST['order_id'];
$product_id = (int) $_POST['product_id'];
exit;
}
if (isset($_POST['update_tracking'])) {
$order_id = (int) $_POST['order_id'];
$product_id = (int) $_POST['product_id'];
$tracking_provider = woocommerce_clean($_POST['tracking_provider']);
$custom_tracking_provider = woocommerce_clean($_POST['custom_tracking_provider']);
$custom_tracking_link = woocommerce_clean($_POST['custom_tracking_link']);
$tracking_number = woocommerce_clean($_POST['tracking_number']);
$date_shipped = woocommerce_clean(strtotime($_POST['date_shipped']));
$order = new WC_Order($order_id);
$products = $order->get_items();
foreach ($products as $key => $value) {
if ($value['product_id'] == $product_id || $value['variation_id'] == $product_id) {
$order_item_id = $key;
break;
}
}
if ($order_item_id) {
woocommerce_delete_order_item_meta($order_item_id, __('Tracking number', 'wcvendors'));
woocommerce_add_order_item_meta($order_item_id, __('Tracking number', 'wcvendors'), $tracking_number);
$message = __('Success. Your tracking number has been updated.', 'wcvendors');
wc_add_notice($message, 'success');
// Update order data
update_post_meta($order_id, '_tracking_provider', $tracking_provider);
update_post_meta($order_id, '_custom_tracking_provider', $custom_tracking_provider);
update_post_meta($order_id, '_tracking_number', $tracking_number);
update_post_meta($order_id, '_custom_tracking_link', $custom_tracking_link);
update_post_meta($order_id, '_date_shipped', $date_shipped);
}
}
$headers = WCV_Orders::get_headers();
$all = WCV_Orders::format_order_details($this->orders, $this->product_id);
wp_enqueue_style('pv_frontend_style', wcv_assets_url . 'css/wcv-frontend.css');
wp_enqueue_script('pv_frontend_script', wcv_assets_url . 'js/front-orders.js');
// WC Shipment Tracking Providers
global $WC_Shipment_Tracking;
$providers = !empty($WC_Shipment_Tracking->providers) ? $WC_Shipment_Tracking->providers : false;
$provider_array = array();
if ($providers) {
foreach ($providers as $providerss) {
foreach ($providerss as $provider => $format) {
$provider_array[sanitize_title($provider)] = urlencode($format);
}
}
}
// End
ob_start();
// Show the Export CSV button
if ($this->can_export_csv) {
wc_get_template('csv-export.php', array(), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/');
}
wc_get_template('orders.php', array('headers' => $headers, 'body' => $all['body'], 'items' => $all['items'], 'product_id' => $all['product_id'], 'providers' => $providers, 'provider_array' => $provider_array), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/');
return ob_get_clean();
}
示例9: can_view_vendor_page
/**
*
*
* @return unknown
*/
public static function can_view_vendor_page()
{
if (!is_user_logged_in()) {
return false;
} else {
if (!WCV_Vendors::is_vendor(get_current_user_id())) {
wc_get_template('denied.php', array(), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/');
return false;
}
}
return true;
}
示例10: tokopress_wcvendors_user_vendorshop
function tokopress_wcvendors_user_vendorshop()
{
$user = get_query_var('author_name') ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
if (WCV_Vendors::is_vendor($user->ID)) {
$shop_name = WCV_Vendors::get_vendor_shop_name($user->ID);
$shop_page = WCV_Vendors::get_vendor_shop_page($user->user_login);
if ($shop_name && $shop_page) {
echo '<div class="user-vendorshop">';
echo '<p>' . sprintf(__('%s is a seller on "%s" shop.', 'tokopress'), '<strong>' . $user->display_name . '</strong>', $shop_name) . '</p>';
echo '<a href="' . $shop_page . '" class="button alt">' . sprintf(__('Visit "%s"', 'tokopress'), $shop_name) . '</a>';
echo '</div>';
}
}
}
示例11: add_vendor_to_order_item_meta
public static function add_vendor_to_order_item_meta($item_id, $cart_item)
{
$vendor_id = $cart_item['data']->post->post_author;
$sold_by_label = WC_Vendors::$pv_options->get_option('sold_by_label');
$sold_by = WCV_Vendors::is_vendor($vendor_id) ? sprintf(WCV_Vendors::get_vendor_sold_by($vendor_id)) : get_bloginfo('name');
wc_add_order_item_meta($item_id, apply_filters('wcvendors_sold_by_in_email', $sold_by_label), $sold_by);
}
示例12: 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));
}
}
}
示例13: sold_by_meta
/**
*
*/
public static function sold_by_meta()
{
$author_id = get_the_author_meta('ID');
$sold_by = WCV_Vendors::is_vendor($author_id) ? sprintf('<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page($author_id), WCV_Vendors::get_vendor_shop_name($author_id)) : get_bloginfo('name');
echo apply_filters('wcvendors_cart_sold_by_meta', __('Sold by: ', 'wcvendors')) . $sold_by . '<br/>';
}
示例14: mango_more_seller_product
function mango_more_seller_product()
{
global $product, $woocommerce_loop;
if (empty($product) || !$product->exists()) {
return;
}
global $post;
if (!WCV_Vendors::is_vendor($post->post_author)) {
return;
}
$meta_query = WC()->query->get_meta_query();
$args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'no_found_rows' => 1, 'posts_per_page' => 10, 'author' => get_the_author_meta('ID'), 'meta_query' => $meta_query, 'orderby' => 'rand');
$products = new WP_Query($args);
if ($products->have_posts()) {
?>
<div class="container">
<h2 class="vendor-moreseller"><?php
_e('More from this seller…', 'mango');
?>
</h2>
<?php
woocommerce_product_loop_start();
?>
<div class="owl-carousel product-featured-carousel">
<?php
while ($products->have_posts()) {
$products->the_post();
?>
<?php
wc_get_template_part('content-product');
?>
<?php
}
// end of the loop.
?>
</div>
<?php
woocommerce_product_loop_end();
?>
</div>
<?php
}
wp_reset_postdata();
}
示例15: vendor_stock_email
/**
* Add the vendor email to the low stock emails.
*
*/
public function vendor_stock_email($emails, $product)
{
if (WCV_Vendors::is_vendor($product->post->post_author)) {
$vendor_data = get_userdata($product->post->post_author);
$vendor_email = $vendor_data->user_email;
$emails .= ',' . $vendor_email;
}
return $emails;
}