本文整理汇总了PHP中wc_add_message函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_add_message函数的具体用法?PHP wc_add_message怎么用?PHP wc_add_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_add_message函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 = PV_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!', 'wc_product_vendor'));
} else {
$woocommerce->add_error(__('You\'ve left the comment field empty!', 'wc_product_vendor'));
}
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.', 'wc_product_vendor'));
} else {
$woocommerce->add_message(__('Success. The customer has been notified of your comment.', 'wc_product_vendor'));
}
}
}
开发者ID:shahadat014,项目名称:geleyi,代码行数:63,代码来源:class-submit-comment.php
示例2: save_vendor_settings
public function save_vendor_settings()
{
if (empty($_POST['vendor_application_submit'])) {
return false;
}
if (!wp_verify_nonce($_POST['wc-product-vendor-nonce'], 'save-shop-settings')) {
return false;
}
global $woocommerce;
$user_id = get_current_user_id();
if (isset($_POST['pv_paypal'])) {
if (!is_email($_POST['pv_paypal'])) {
if (function_exists('wc_add_error')) {
wc_add_error(__('Your PayPal address is not a valid email address.', 'wc_product_vendor'));
} else {
$woocommerce->add_error(__('Your PayPal address is not a valid email address.', 'wc_product_vendor'));
}
} 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) {
if (function_exists('wc_add_error')) {
wc_add_error(__('That shop name is already taken. Your shop name must be unique.', 'wc_product_vendor'));
} else {
$woocommerce->add_error(__('That shop name is already taken. Your shop name must be unique.', 'wc_product_vendor'));
}
} 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('wc_product_vendor_shop_settings_saved', $user_id);
if (!$woocommerce->error_count()) {
if (function_exists('wc_add_message')) {
wc_add_message(__('Settings saved.', 'wc_product_vendor'));
} else {
$woocommerce->add_message(__('Settings saved.', 'wc_product_vendor'));
}
}
}
开发者ID:shahadat014,项目名称:geleyi,代码行数:49,代码来源:class-vendor-dashboard.php
示例3: add_payment_method_action
/**
* Process the add payment method form.
*/
public static function add_payment_method_action()
{
if (isset($_POST['woocommerce_add_payment_method']) && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-add-payment-method')) {
ob_start();
$payment_method = wc_clean($_POST['payment_method']);
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
// Validate
$available_gateways[$payment_method]->validate_fields();
// Process
if (wc_notice_count('wc_errors') == 0) {
$result = $available_gateways[$payment_method]->add_payment_method();
// Redirect to success/confirmation/payment page
if ($result['result'] == 'success') {
wc_add_message(__('Payment method added.', 'woocommerce'));
wp_redirect($result['redirect']);
exit;
}
}
}
}
开发者ID:nightbook,项目名称:woocommerce,代码行数:23,代码来源:class-wc-form-handler.php
示例4: save_pending
/**
*
*
* @param unknown $user_id
*/
public function save_pending($user_id)
{
if (isset($_POST['apply_for_vendor'])) {
global $woocommerce;
if (function_exists('wc_clear_messages')) {
wc_clear_messages();
} else {
$woocommerce->clear_messages();
}
if (user_can($user_id, 'manage_options')) {
if (function_exists('wc_add_error')) {
wc_add_error(__('Application denied. You are an administrator.', 'wc_product_vendor'));
} else {
$woocommerce->add_error(__('Application denied. You are an administrator.', 'wc_product_vendor'));
}
} else {
if (function_exists('wc_add_message')) {
wc_add_message(__('Your application has been submitted.', 'wc_product_vendor'));
} else {
$woocommerce->add_message(__('Your application has been submitted.', 'wc_product_vendor'));
}
$manual = Product_Vendor::$pv_options->get_option('manual_vendor_registration');
$role = apply_filters('wc_product_vendor_pending_role', $manual ? 'pending_vendor' : 'vendor');
$wp_user_object = new WP_User($user_id);
$wp_user_object->set_role($role);
do_action('wc_product_vendor_application_submited', $user_id);
add_filter('woocommerce_registration_redirect', array('PV_Vendor_Signup', 'redirect_to_vendor_dash'));
}
}
}
开发者ID:shahadat014,项目名称:geleyi,代码行数:35,代码来源:class-vendor-signup.php
示例5: 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();
woocommerce_get_template('denied.php', array(), 'wc-product-vendor/dashboard/', wcv_plugin_dir . 'views/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(2048, __('Tracking number', 'wcvendors'));
woocommerce_add_order_item_meta(2048, __('Tracking number', 'wcvendors'), $tracking_number);
$message = __('Success. Your tracking number has been updated.', 'wcvendors');
if (function_exists('wc_add_message')) {
wc_add_message($message);
} else {
$woocommerce->add_message($message);
}
// 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/pv-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) {
woocommerce_get_template('csv-export.php', array(), 'wc-product-vendor/orders/', wcv_plugin_dir . 'views/orders/');
}
woocommerce_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-product-vendor/orders/', wcv_plugin_dir . 'views/orders/');
return ob_get_clean();
}
开发者ID:shubham79,项目名称:Jhintaak,代码行数:84,代码来源:class-orders.php
示例6: 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'];
$shippers = (array) get_post_meta($order_id, 'wc_pv_shipped', true);
if (in_array($user_id, $shippers)) {
foreach ($shippers as $key => $value) {
if ($value == $user_id) {
unset($shippers[$key]);
if (function_exists('wc_add_error')) {
wc_add_error(__('Order unmarked shipped.', 'wcvendors'));
} else {
$woocommerce->add_error(__('Order unmarked shipped.', 'wcvendors'));
}
break;
}
}
} else {
$shippers[] = $user_id;
$mails = $woocommerce->mailer()->get_emails();
if (!empty($mails)) {
$mails['WC_Email_Notify_Shipped']->trigger($order_id, $user_id);
}
if (function_exists('wc_add_message')) {
wc_add_message(__('Order marked shipped.', 'wcvendors'));
} else {
$woocommerce->add_message(__('Order marked shipped.', 'wcvendors'));
}
}
update_post_meta($order_id, 'wc_pv_shipped', $shippers);
return;
}
if (empty($_POST['vendor_application_submit'])) {
return false;
}
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'])) {
if (function_exists('wc_add_error')) {
wc_add_error(__('Your PayPal address is not a valid email address.', 'wcvendors'));
} else {
$woocommerce->add_error(__('Your PayPal address is not a valid email address.', 'wcvendors'));
}
} 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) {
if (function_exists('wc_add_error')) {
wc_add_error(__('That shop name is already taken. Your shop name must be unique.', 'wcvendors'));
} else {
$woocommerce->add_error(__('That shop name is already taken. Your shop name must be unique.', 'wcvendors'));
}
} 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()) {
if (function_exists('wc_add_message')) {
wc_add_message(__('Settings saved.', 'wcvendors'));
} else {
wc_add_notice(__('Settings saved.', 'wcvendors'));
}
}
}
开发者ID:shubham79,项目名称:Jhintaak,代码行数:79,代码来源:class-vendor-dashboard.php
注:本文中的wc_add_message函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论