本文整理汇总了PHP中WCV_Vendors::get_vendors_from_order方法的典型用法代码示例。如果您正苦于以下问题:PHP WCV_Vendors::get_vendors_from_order方法的具体用法?PHP WCV_Vendors::get_vendors_from_order怎么用?PHP WCV_Vendors::get_vendors_from_order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WCV_Vendors
的用法示例。
在下文中一共展示了WCV_Vendors::get_vendors_from_order方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: append_actions
public function append_actions($order, $order_page = false)
{
global $woocommerce;
$authors = WCV_Vendors::get_vendors_from_order($order);
$authors = $authors ? array_keys($authors) : array();
if (empty($authors)) {
return false;
}
$shipped = (array) get_post_meta($order->id, 'wc_pv_shipped', true);
$string = '</br></br>';
foreach ($authors as $author) {
$string .= in_array($author, $shipped) ? '✔ ' : '✕ ';
$string .= WCV_Vendors::get_vendor_shop_name($author);
$string .= '</br>';
}
$response = array('url' => '#', 'name' => __('Vendors Shipped', 'wcvendors') . $string, 'action' => 'wc_pv_shipped', 'image_url' => wcv_assets_url . '/images/icons/truck.png');
if (!$order_page) {
printf('<a class="button tips %s" href="%s" data-tip="%s"><img style="width:16px;height:16px;" src="%s"></a>', $response['action'], $response['url'], $response['name'], $response['image_url']);
} else {
echo $response['name'];
}
return $response;
}
示例2: save_vendor_settings
public function save_vendor_settings()
{
global $woocommerce;
$user_id = get_current_user_id();
if (!empty($_GET['wc_pv_mark_shipped'])) {
$order_id = $_GET['wc_pv_mark_shipped'];
$order = wc_get_order($order_id);
$vendors = WCV_Vendors::get_vendors_from_order($order);
$vendor_ids = array_keys($vendors);
if (!in_array($user_id, $vendor_ids)) {
wc_add_notice(__('You are not allowed to modify this order.', 'wcvendors'));
return null;
}
$shippers = (array) get_post_meta($order_id, 'wc_pv_shipped', true);
// 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');
$shop_name = WCV_Vendors::get_vendor_shop_name($user_id);
$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');
}
}
}
示例3: mark_shipped
/**
* Mark orders as shipped
*
* @param unknown $ids (optional)
*
* @return unknown
*/
public function mark_shipped($ids = array())
{
global $woocommerce;
$user_id = get_current_user_id();
if (!empty($ids)) {
foreach ($ids as $order_id) {
$order = wc_get_order($order_id);
$vendors = WCV_Vendors::get_vendors_from_order($order);
$vendor_ids = array_keys($vendors);
if (!in_array($user_id, $vendor_ids)) {
wp_die(__('You are not allowed to modify this order.', 'wcvendors'));
}
$shippers = (array) get_post_meta($order_id, 'wc_pv_shipped', true);
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);
}
update_post_meta($order_id, 'wc_pv_shipped', $shippers);
}
return true;
}
return false;
}