本文整理汇总了PHP中yith_get_vendor函数的典型用法代码示例。如果您正苦于以下问题:PHP yith_get_vendor函数的具体用法?PHP yith_get_vendor怎么用?PHP yith_get_vendor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了yith_get_vendor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query_report_data
/**
* Get all data needed for this report and store in the class
*/
private function query_report_data()
{
$vendor = yith_get_vendor('current', 'user');
if (!$vendor->is_valid() && !$vendor->has_limited_access()) {
return false;
}
$this->report_data = new stdClass();
$date_query = YITH_Reports()->get_wp_query_date_args($this->start_date, $this->end_date);
$query_args = array_merge(array('vendor_id' => $vendor->id), $date_query);
$commission_status = YITH_Commissions()->get_status();
$commission_status['all'] = 'all';
foreach ($commission_status as $key => $value) {
$commission_ids = YITH_Commissions()->get_commissions(array_merge($query_args, array('status' => $key)));
$data = "commissions_{$key}";
$data_amount = "{$data}_amount";
$data_count = "{$data}_count";
$this->report_data->{$data_amount} = 0;
foreach ($commission_ids as $commision_id) {
$commission = YITH_Commission($commision_id);
if ('all' == $key && ('cancelled' == $commission->status || 'refunded' == $commission->status)) {
continue;
}
$this->report_data->{$data}[$commision_id] = new stdClass();
$this->report_data->{$data}[$commision_id]->amount = $this->round_chart_totals($commission->get_amount());
$this->report_data->{$data}[$commision_id]->commission_date = $commission->get_date();
$this->report_data->{$data_count}[$commision_id] = new stdClass();
$this->report_data->{$data_count}[$commision_id]->count = 1;
$this->report_data->{$data_count}[$commision_id]->commission_date = $commission->get_date();
$this->report_data->{$data_amount} += $commission->get_amount();
}
}
}
示例2: widget
/**
* Echo the widget content.
*
* Subclasses should over-ride this function to generate their widget code.
*
* @param array $args Display arguments including before_title, after_title,
* before_widget, and after_widget.
* @param array $instance The settings for the particular instance of the widget.
*
* @author Andrea Grillo <andrea.grillo@yithemes.com>
*/
public function widget($args, $instance)
{
$vendor = yith_get_vendor(get_query_var('term'));
if (YITH_Vendors()->frontend->is_vendor_page() && !empty($vendor->location)) {
$args = array('instance' => $instance, 'vendor' => $vendor, 'gmaps_link' => esc_url(add_query_arg(array('q' => urlencode($vendor->location)), '//maps.google.com/')));
yith_wcpv_get_template('store-location', $args, 'widgets');
}
}
示例3: become_a_vendor
public static function become_a_vendor($sc_args = array())
{
$user = wp_get_current_user();
$vendor = yith_get_vendor($user->ID, 'user');
if (!$vendor->is_valid() && (in_array('subscriber', $user->roles) || in_array('customer', $user->roles)) || $vendor->is_super_user()) {
$args = array('is_vat_require' => YITH_Vendors()->is_vat_require(), 'is_terms_and_conditions_require' => YITH_Vendors()->is_terms_and_conditions_require());
yith_wcpv_get_template('become-a-vendor', $args, 'shortcodes');
} else {
YITH_Vendors()->frontend->vendor_dashboard_endpoint($vendor);
}
}
示例4: column_default
/**
* Print the columns information
*
* @param $rec \YITH_Commission
* @param $column_name
*
* @return string
*/
public function column_default($rec, $column_name)
{
switch ($column_name) {
case 'user':
if (empty($rec->display_name)) {
return "<em>" . __('User deleted', 'yith_wc_product_vendors') . "</em>";
}
$user_url = get_edit_user_link($rec->ID);
$user_name = $rec->display_name;
return !empty($user_url) ? "<a href='{$user_url}' target='_blank'>{$user_name}</a>" : $user_name;
break;
case 'vendor':
$vendor = yith_get_vendor($rec->ID, 'user');
if (!$vendor->is_valid()) {
return "<em>" . __('Vendor deleted', 'yith_wc_product_vendors') . "</em>";
}
$vendor_url = get_edit_term_link($vendor->id, $vendor->taxonomy);
$vendor_name = $vendor->name;
return !empty($vendor_url) ? "<a href='{$vendor_url}' target='_blank'>{$vendor_name}</a>" : $vendor_name;
break;
case 'amount':
$amount = get_user_meta($rec->ID, '_vendor_commission_credit', true);
return wc_price($amount);
break;
case 'user_actions':
if ($this->_vendor->is_super_user()) {
printf('<a class="button tips pay" href="%1$s" data-tip="%2$s">%2$s</a>', esc_url(wp_nonce_url(add_query_arg(array('action' => 'pay_commission', 'commission_id' => $rec->ID), admin_url('admin.php')), 'yith-vendors-pay-commission')), __('Pay', 'yith_wc_product_vendors'));
}
break;
case 'oldest_commission':
$commissions = YITH_Commissions()->get_commissions(array('user_id' => $rec->ID, 'fields' => 'last_edit', 'order' => 'ASC'));
$oldest_commission_date = array_shift($commissions);
$t_time = date_i18n(__('Y/m/d g:i:s A'), mysql2date('U', $oldest_commission_date));
$m_time = $oldest_commission_date;
$time = mysql2date('G', $oldest_commission_date);
$time_diff = time() - $time;
if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
$h_time = sprintf(__('%s ago'), human_time_diff($time));
} else {
$h_time = mysql2date(__('Y/m/d'), $m_time);
}
return $h_time ? '<abbr title="' . $t_time . '">' . $h_time . '</abbr>' : '<small class="meta">-</small>';
break;
}
return null;
}
开发者ID:kanhaiyasharma,项目名称:Bestswiss,代码行数:54,代码来源:class.yith-commissions-earnings-by-vendor-table.php
示例5: trigger
/**
* trigger function.
*
* @access public
* @return void
*/
function trigger($order_id)
{
if (!$this->is_enabled() || empty($vendors) || empty($order_id)) {
return false;
}
$this->object = wc_get_order($order_id);
$this->vendor = yith_get_vendor($this->object->post->post_author, 'user');
if (!$this->vendor->is_valid()) {
return false;
}
$this->find['order-date'] = '{order_date}';
$this->find['order-number'] = '{order_number}';
$this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
$this->replace['order-number'] = $this->object->get_order_number();
$vendor_email = $this->vendor->store_email;
if (empty($vendor_email)) {
$vendor_owner = get_user_by('id', absint($this->vendor->get_owner()));
$vendor_email = $vendor_owner instanceof WP_User ? $vendor_owner->user_email : false;
}
$this->send($vendor_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
}
示例6: filter_report_stock_query_from
/**
* Get the allowed vendors post id
*
* @param $query_from The query FROM
*
* @return array The post id
*/
public function filter_report_stock_query_from($query_from)
{
$vendor = yith_get_vendor('current', 'user');
if ($vendor->is_valid() && $vendor->has_limited_access()) {
$product_ids = implode(",", $vendor->get_products());
$query_from .= "AND posts.ID IN ({$product_ids})";
}
return $query_from;
}
示例7: commissions_order_column
/**
* Filter the order link, if vendor has access
*
* @param $value The string to output
* @param $order_id The order id
*
* @return string The output string
* @since 1.6
*/
public function commissions_order_column($value, $order_id)
{
$vendor = yith_get_vendor('current', 'user');
if ($vendor->is_valid() && $vendor->has_limited_access() && wp_get_post_parent_id($order_id) && in_array($order_id, $vendor->get_orders())) {
$value = '<a href="' . admin_url('post.php?post=' . absint($order_id) . '&action=edit') . '">' . $value . '</a>';
}
return $value;
}
示例8: remove_wp_bar_admin_menu
/**
* Remove new post and comments wp bar admin menu for vendor
*
* @author Andrea Grillo <andrea.grillo@yithemes.com>
* @since 1.5.1
* @return void
*/
public function remove_wp_bar_admin_menu()
{
$vendor = yith_get_vendor('current', 'user');
if ($vendor->is_valid() && $vendor->has_limited_access()) {
remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
remove_action('admin_bar_menu', 'wp_admin_bar_new_content_menu', 70);
}
}
示例9: exit_direct_access_no_selling_capabilities
/**
* exit if the vendor account hasn't selling capabilities
*
* @return string The title
* @since 1.0
* @author Andrea Grillo <andrea.grillo@yithemes.com>
* @use template_redirect filter
*/
public function exit_direct_access_no_selling_capabilities()
{
global $post;
if (is_singular('product')) {
$vendor = yith_get_vendor($post, 'product');
if ($vendor && 'no' == $vendor->enable_selling) {
$this->redirect_404();
}
}
}
示例10: vendor_count_posts
/**
* Filter the post count for vendor
*
* @author Andrea Grillo <andrea.grillo@yithemes.com>
*
* @param $counts The post count
* @param $type Post type
* @param $perm The read permission
*
* @return arr Modified request
* @since 1.0
* @use wp_post_count action
*/
public function vendor_count_posts($counts, $type, $perm)
{
$vendor = yith_get_vendor('current', 'user');
if (!$vendor || !in_array($type, $this->vendor_allowed_post_types) || $vendor->is_super_user() || !$vendor->is_user_admin()) {
return $counts;
}
/**
* Get a list of post statuses.
*/
$stati = get_post_stati();
// Update count object
foreach ($stati as $status) {
$posts = $this->get_vendor_posts($vendor, $type, "post_status={$status}");
$counts->{$status} = count($posts);
}
return $counts;
}
示例11: vendor_count_coupons
/**
* Filter the post count for vendor
*
* @author Andrea Grillo <andrea.grillo@yithemes.com>
*
* @param $counts The post count
* @param $type Post type
* @param $perm The read permission
*
* @return arr Modified request
* @since 1.3
* @use wp_post_count action
*/
public function vendor_count_coupons($counts, $type, $perm)
{
$vendor = yith_get_vendor('current', 'user');
if ($vendor->is_valid() && $vendor->has_limited_access() && 'shop_coupon' == $type) {
$args = array('post_type' => $type, 'author__in' => $vendor->get_admins());
/**
* Get a list of post statuses.
*/
$stati = get_post_stati();
// Update count object
foreach ($stati as $status) {
$args['post_status'] = $status;
$posts = get_posts($args);
$counts->{$status} = count($posts);
}
}
return $counts;
}
示例12: nielsen_theme_support
/**
* Nielsen theme shop loop compatibility
*
* @param $check The filter value for add to cart/show details value
*
* @return bool validation result
*
* @since 1.8.3
* @author Andrea Grillo <andrea.grillo@yithemes.com>
*/
public function nielsen_theme_support($check)
{
global $product;
$vendor = yith_get_vendor($product, 'product');
return $vendor->is_valid() && $vendor->is_on_vacation() && 'disabled' == $vendor->vacation_selling ? true : $check;
}
示例13: get_order_items_by_vendor
/**
* Retrieve all items from an order, grouping all by vendor
*
* @param int $parent_order_id the parent order id
* @param array $args additional parameters
*
* @return array
* @author Lorenzo Giuffrida
* @since 1.6.0
*/
public static function get_order_items_by_vendor($parent_order_id, $args = array())
{
/**
* Define the array of defaults
*/
$defaults = array('hide_no_vendor' => false, 'hide_without_shipping' => false);
/**
* Parse incoming $args into an array and merge it with $defaults
*/
$args = wp_parse_args($args, $defaults);
$parent_order = wc_get_order($parent_order_id);
$items = $parent_order->get_items();
$product_by_vendor = array();
//check for vendor product
foreach ($items as $item_id => $item) {
$vendor = yith_get_vendor($item['product_id'], 'product');
$vendor_id = 0;
if ($vendor->is_valid($vendor)) {
$vendor_id = $vendor->id;
}
// optionally skip product without vendor
if ($args["hide_no_vendor"] && !$vendor_id) {
continue;
}
// optionally skip product without ship
if ($args["hide_without_shipping"]) {
$product_id = $item["product_id"];
if (0 != $item["variation_id"]) {
$product_id = $item["variation_id"];
}
$product = wc_get_product($product_id);
if (!$product->needs_shipping()) {
continue;
}
}
$product_by_vendor[$vendor_id][$item_id] = $item;
}
return $product_by_vendor;
}
示例14: current_filters
/**
* Show current filters
*/
public function current_filters()
{
$this->vendor_ids_name = array();
$vendor = yith_get_vendor($this->vendor_ids);
if ($vendor->is_valid()) {
$this->vendor_ids_name[] = $vendor->name;
} else {
$this->vendor_ids_name[] = '#' . $vendor->id;
}
echo '<p>' . ' <strong>' . implode(', ', $this->vendor_ids_name) . '</strong></p>';
echo '<p><a class="button" href="' . esc_url(remove_query_arg('vendor_ids')) . '">' . __('Reset', 'yith_wc_product_vendors') . '</a></p>';
}
示例15: __construct
/**
* Construct
*/
public function __construct()
{
//Set parent defaults
parent::__construct(array('singular' => 'commission', 'plural' => 'commissions', 'ajax' => false));
$this->_vendor = yith_get_vendor('current', 'user');
}