/** * * * @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_shop_name($product->post_author)) : get_bloginfo('name'); $name .= '<small><br />' . apply_filters('wcvendors_sold_by_in_email', __('Sold by: ', 'wcvendors')) . $sold_by . '</small><br />'; return $name; }
public function filter_comment($commentdata, $order) { $user_id = get_current_user_id(); $commentdata['user_id'] = $user_id; $commentdata['comment_author'] = WCV_Vendors::get_vendor_shop_name($user_id); $commentdata['comment_author_url'] = WCV_Vendors::get_vendor_shop_page($user_id); $commentdata['comment_author_email'] = wp_get_current_user()->user_email; return $commentdata; }
/** * 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()); }
/** * 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()); }
public static function get_vendor_sold_by($vendor_id) { $vendor_display_name = WC_Vendors::$pv_options->get_option('vendor_display_name'); $vendor = get_userdata($vendor_id); switch ($vendor_display_name) { case 'display_name': $display_name = $vendor->display_name; break; case 'user_login': $display_name = $vendor->user_login; break; case 'user_email': $display_name = $vendor->user_email; break; default: $display_name = WCV_Vendors::get_vendor_shop_name($vendor_id); break; } return $display_name; }
public function save_vendor_settings() { global $woocommerce; $user_id = get_current_user_id(); if (!empty($_GET['wc_pv_mark_shipped'])) { $shop_name = WCV_Vendors::get_vendor_shop_name($user_id); $order_id = $_GET['wc_pv_mark_shipped']; $shippers = (array) get_post_meta($order_id, 'wc_pv_shipped', true); $order = new WC_Order($order_id); // If not in the shippers array mark as shipped otherwise do nothing. if (!in_array($user_id, $shippers)) { $shippers[] = $user_id; $mails = $woocommerce->mailer()->get_emails(); if (!empty($mails)) { $mails['WC_Email_Notify_Shipped']->trigger($order_id, $user_id); } do_action('wcvendors_vendor_ship', $order_id, $user_id); wc_add_notice(__('Order marked shipped.', 'wcvendors'), 'success'); $order->add_order_note(apply_filters('wcvendors_vendor_shipped_note', __($shop_name . ' has marked as shipped. ', 'wcvendors')), $user_id); } elseif (false != ($key = array_search($user_id, $shippers))) { unset($shippers[$key]); // Remove user from the shippers array } update_post_meta($order_id, 'wc_pv_shipped', $shippers); return; } 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_name']); $custom_tracking_link = woocommerce_clean($_POST['custom_tracking_url']); $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); } } if (empty($_POST['vendor_application_submit'])) { return false; } if (isset($_POST['wc-product-vendor-nonce'])) { if (!wp_verify_nonce($_POST['wc-product-vendor-nonce'], 'save-shop-settings')) { return false; } if (isset($_POST['pv_paypal'])) { if (!is_email($_POST['pv_paypal'])) { wc_add_notice(__('Your PayPal address is not a valid email address.', 'wcvendors'), 'error'); } else { update_user_meta($user_id, 'pv_paypal', $_POST['pv_paypal']); } } if (!empty($_POST['pv_shop_name'])) { $users = get_users(array('meta_key' => 'pv_shop_slug', 'meta_value' => sanitize_title($_POST['pv_shop_name']))); if (!empty($users) && $users[0]->ID != $user_id) { wc_add_notice(__('That shop name is already taken. Your shop name must be unique.', 'wcvendors'), 'error'); } else { update_user_meta($user_id, 'pv_shop_name', $_POST['pv_shop_name']); update_user_meta($user_id, 'pv_shop_slug', sanitize_title($_POST['pv_shop_name'])); } } if (isset($_POST['pv_shop_description'])) { update_user_meta($user_id, 'pv_shop_description', $_POST['pv_shop_description']); } if (isset($_POST['pv_seller_info'])) { update_user_meta($user_id, 'pv_seller_info', $_POST['pv_seller_info']); } do_action('wcvendors_shop_settings_saved', $user_id); if (!wc_notice_count()) { wc_add_notice(__('Settings saved.', 'wcvendors'), 'success'); } } }
$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; case 'user_login': $vendor_name = $vendor->user_login; break; default: $vendor_name = WCV_Vendors::get_vendor_shop_name($vendor_id); break; } $vendor_description = do_shortcode(get_user_meta($vendor_id, 'pv_shop_description', true)); $has_html = get_user_meta($vendor_id, 'pv_shop_html_enabled', true); $global_html = WC_Vendors::$pv_options->get_option('shop_html_enabled'); $store_banner = get_user_meta($vendor_id, 'tppv_shop_banner', true); $store_info = ''; if ($vendor_name) { $store_info .= '<li class="store-name">' . esc_html($vendor_name) . '</li>'; } if (trim($vendor_description)) { $store_info .= '<li class="store-description">' . ($global_html || $has_html) ? wpautop(wptexturize(wp_kses_post($vendor_description))) : sanitize_text_field($vendor_description) . '</li>'; } $store_contact = ''; if ($vendor_profile) {
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>'; } } }
public static function page_title($page_title = "") { $vendor_shop = urldecode(get_query_var('vendor_shop')); $vendor_id = WCV_Vendors::get_vendor_id($vendor_shop); return $vendor_id ? WCV_Vendors::get_vendor_shop_name($vendor_id) : $page_title; }
/** * column_default function. * * @access public * * @param unknown $item * @param mixed $column_name * * @return unknown */ function column_default($item, $column_name) { global $wpdb; switch ($column_name) { case 'id': return $item->id; case 'vendor_id': $user = get_userdata($item->vendor_id); return '<a href="' . admin_url('user-edit.php?user_id=' . $item->vendor_id) . '">' . WCV_Vendors::get_vendor_shop_name($item->vendor_id) . '</a>'; case 'total_due': return woocommerce_price($item->total_due + $item->total_shipping + $item->tax); case 'product_id': $parent = get_post_ancestors($item->product_id); $product_id = $parent ? $parent[0] : $item->product_id; return '<a href="' . admin_url('post.php?post=' . $product_id . '&action=edit') . '">' . get_the_title($item->product_id) . '</a>'; case 'order_id': return '<a href="' . admin_url('post.php?post=' . $item->order_id . '&action=edit') . '">' . $item->order_id . '</a>'; case 'status': return $item->status; case 'time': return date_i18n(get_option('date_format'), strtotime($item->time)); } }
/** * */ function sales() { global $start_date, $end_date, $woocommerce, $wpdb; $start_date = !empty($_POST['start_date']) ? $_POST['start_date'] : strtotime(date('Ymd', strtotime(date('Ym', current_time('timestamp')) . '01'))); $end_date = !empty($_POST['end_date']) ? $_POST['end_date'] : strtotime(date('Ymd', current_time('timestamp'))); if (!empty($_POST['start_date'])) { $start_date = strtotime($_POST['start_date']); } if (!empty($_POST['end_date'])) { $end_date = strtotime($_POST['end_date']); } $after = date('Y-m-d', $start_date); $before = date('Y-m-d', strtotime('+1 day', $end_date)); $commission_due = $wpdb->get_var("\n\t\t\tSELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'due'\n\t\t\tAND time >= '" . $after . "'\n\t\t\tAND time <= '" . $before . "'\n\t\t"); $reversed = $wpdb->get_var("\n\t\t\tSELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'reversed'\n\t\t\tAND time >= '" . $after . "'\n\t\t\tAND time <= '" . $before . "'\n\t\t"); $paid = $wpdb->get_var("\n\t\t\tSELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'paid'\n\t\t\tAND time >= '" . $after . "'\n\t\t\tAND time <= '" . $before . "'\n\t\t"); ?> <form method="post" action=""> <p><label for="from"><?php _e('From:', 'wcvendors'); ?> </label> <input type="text" size="9" placeholder="yyyy-mm-dd" value="<?php echo esc_attr(date('Y-m-d', $start_date)); ?> " name="start_date" class="range_datepicker from" id="from" /> <label for="to"><?php _e('To:', 'wcvendors'); ?> </label> <input type="text" size="9" placeholder="yyyy-mm-dd" value="<?php echo esc_attr(date('Y-m-d', $end_date)); ?> " name="end_date" class="range_datepicker to" id="to" /> <input type="submit" class="button" value="<?php _e('Show', 'wcvendors'); ?> "/></p> </form> <div id="poststuff" class="woocommerce-reports-wrap"> <div class="woocommerce-reports-sidebar"> <div class="postbox"> <h3><span><?php _e('Total paid in range', 'wcvendors'); ?> </span></h3> <div class="inside"> <p class="stat"><?php if ($paid > 0) { echo woocommerce_price($paid); } else { _e('n/a', 'wcvendors'); } ?> </p> </div> </div> <div class="postbox"> <h3><span><?php _e('Total due in range', 'wcvendors'); ?> </span></h3> <div class="inside"> <p class="stat"><?php if ($commission_due > 0) { echo woocommerce_price($commission_due); } else { _e('n/a', 'wcvendors'); } ?> </p> </div> </div> <div class="postbox"> <h3><span><?php _e('Total reversed in range', 'wcvendors'); ?> </span></h3> <div class="inside"> <p class="stat"><?php if ($reversed > 0) { echo woocommerce_price($reversed); } else { _e('n/a', 'wcvendors'); } ?> </p> </div> </div> </div> <div class="woocommerce-reports-main"> <div class="postbox"> <h3><span><?php _e('Recent Commission', 'wcvendors'); ?> </span></h3> <div> <?php $commission = $wpdb->get_results("\n\t\t\t\t\t\t\t\tSELECT * FROM {$wpdb->prefix}pv_commission\n\t\t\t\t\t\t\t\tWHERE time >= '" . $after . "'\n\t\t\t\t\t\t\t\tAND time <= '" . $before . "'\n\t\t\t\t\t\t\t\tORDER BY time DESC\n\t\t\t\t\t\t\t"); if (sizeof($commission) > 0) { ?> <div class="woocommerce_order_items_wrapper"> <table id="commission-table" class="woocommerce_order_items" cellspacing="0"> <thead> <tr> <th><?php _e('Order', 'wcvendors'); ?> </th> <th><?php _e('Product', 'wcvendors'); ?> </th> <th><?php _e('Vendor', 'wcvendors'); ?> </th> <th><?php _e('Total', 'wcvendors'); ?> </th> <th><?php _e('Date & Time', 'wcvendors'); ?> </th> <th><?php _e('Status', 'wcvendors'); ?> </th> </tr> </thead> <tbody> <?php $i = 1; foreach ($commission as $row) { $i++; ?> <tr<?php if ($i % 2 == 1) { echo ' class="alternate"'; } ?> > <td><?php if ($row->order_id) { ?> <a href="<?php echo admin_url('post.php?post=' . $row->order_id . '&action=edit'); ?> "><?php echo $row->order_id; ?> </a><?php } else { _e('N/A', 'wcvendors'); } ?> </td> <td><?php echo get_the_title($row->product_id); ?> </td> <td><?php echo WCV_Vendors::get_vendor_shop_name($row->vendor_id); ?> </td> <td><?php echo woocommerce_price($row->total_due + $row->total_shipping + $row->tax); ?> </td> <td><?php echo date(__('D j M Y \\a\\t h:ia', 'wcvendors'), strtotime($row->time)); ?> </td> <td><?php echo $row->status; ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php } else { ?> <p><?php _e('No commission yet', 'wcvendors'); ?> </p><?php } ?> </div> </div> </div> </div> <?php }
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 />'; }
function mango_wc_vendors_sold_by_meta() { global $mango_settings; $author_id = get_the_author_meta('ID'); $vendor_display_name = WC_Vendors::$pv_options->get_option('vendor_display_name'); switch ($vendor_display_name) { case 'display_name': $vendor = get_userdata($author_id); $vendor_name = $vendor->display_name; break; case 'user_login': $vendor = get_userdata($author_id); $vendor_name = $vendor->user_login; break; default: $vendor_name = WCV_Vendors::get_vendor_shop_name($author_id); break; } $sold_by = WCV_Vendors::is_vendor($author_id) ? sprintf('<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page($author_id), $vendor_name) : get_bloginfo('name'); if ($mango_settings['mango_wcvendors_product_soldby']) { echo '<ul class="list-item-details"><li><span class="data-type">' . __('Sold by : ', 'mango') . '</span><span class="value">' . $sold_by . '</span></li></ul>'; } }
//gets url of members profile dashboard based on current user id if ($can_submit) { ?> <a target="_TOP" href="<?php echo $profile_url . 'products/products-create'; ?> " class="button"><?php echo _e('Add New Product', 'wcvendors'); ?> </a> <a target="_TOP" href="<?php echo $profile_url . 'products/products-my-posts'; ?> " class="button"><?php echo _e('Edit Products', 'wcvendors'); ?> </a> <?php } ?> </center> <hr> <?php $author_id = get_current_user_id(); $shop_name_set = WCV_Vendors::get_vendor_shop_name($author_id); $vendor_login = get_userdata($author_id); if ($shop_name_set == $vendor_login->user_login) { //outputs warning to vendor if they haven't configured their shop settings echo '<div class="alert alert-danger"><h4>You need to set up your shop!</h4><p>Also don\'t forget to set your paypal email address in the shop settings to receive payments.<br><br><a href="' . $settings_page . '">Click here to set up your shop.</a>.</p></div>'; }
/** * */ 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/>'; }