function dokan_account_migration_button() { $user = wp_get_current_user(); if (dokan_is_user_customer($user->ID)) { ?> <p> </p> <p> <a href="<?php echo dokan_get_page_url('myaccount', 'woocommerce'); ?> account-migration/seller/" class="button button-primary"><?php _e('Become a Seller', 'dokan'); ?> </a> </p> <?php } }
/** * Get coupon edit url * * @param int $coupon_id * @param string $coupon_page * @return string */ function dokan_get_coupon_edit_url($coupon_id, $coupon_page = '') { if (!$coupon_page) { $coupon_page = dokan_get_page_url('coupons'); } $edit_url = wp_nonce_url(add_query_arg(array('post' => $coupon_id, 'action' => 'edit', 'view' => 'add_coupons'), $coupon_page), '_coupon_nonce', 'coupon_nonce_url'); return $edit_url; }
/** * User top navigation menu * * @return void */ function dokan_header_user_menu() { ?> <ul class="nav navbar-nav navbar-right"> <li> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php printf(__('Cart %s', 'dokan'), '<span class="dokan-cart-amount-top">(' . WC()->cart->get_cart_total() . ')</span>'); ?> <b class="caret"></b></a> <ul class="dropdown-menu"> <li> <div class="widget_shopping_cart_content"></div> </li> </ul> </li> <?php if (is_user_logged_in()) { ?> <?php global $current_user; $user_id = $current_user->ID; if (dokan_is_user_seller($user_id)) { ?> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php _e('Seller Dashboard', 'dokan'); ?> <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="<?php echo dokan_get_store_url($user_id); ?> " target="_blank"><?php _e('Visit your store', 'dokan'); ?> <i class="fa fa-external-link"></i></a></li> <li class="divider"></li> <?php $nav_urls = dokan_get_dashboard_nav(); foreach ($nav_urls as $key => $item) { printf('<li><a href="%s">%s %s</a></li>', $item['url'], $item['icon'], $item['title']); } ?> </ul> </li> <?php } ?> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo esc_html($current_user->display_name); ?> <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="<?php echo dokan_get_page_url('my_orders'); ?> "><?php _e('My Orders', 'dokan'); ?> </a></li> <li><a href="<?php echo dokan_get_page_url('myaccount', 'woocommerce'); ?> "><?php _e('My Account', 'dokan'); ?> </a></li> <li><a href="<?php echo wc_customer_edit_account_url(); ?> "><?php _e('Edit Account', 'dokan'); ?> </a></li> <li class="divider"></li> <li><a href="<?php echo wc_get_endpoint_url('edit-address', 'billing', get_permalink(wc_get_page_id('myaccount'))); ?> "><?php _e('Billing Address', 'dokan'); ?> </a></li> <li><a href="<?php echo wc_get_endpoint_url('edit-address', 'shipping', get_permalink(wc_get_page_id('myaccount'))); ?> "><?php _e('Shipping Address', 'dokan'); ?> </a></li> </ul> </li> <li><?php wp_loginout(home_url()); ?> </li> <?php } else { ?> <li><a href="<?php echo dokan_get_page_url('myaccount', 'woocommerce'); ?> "><?php _e('Log in', 'dokan'); ?> </a></li> <li><a href="<?php echo dokan_get_page_url('myaccount', 'woocommerce'); ?> "><?php _e('Sign Up', 'dokan'); ?> </a></li> <?php } ?> </ul> <?php }
/** * Handles the become a seller form * * @return void */ function dokan_become_seller_handler() { if (isset($_POST['dokan_migration']) && wp_verify_nonce($_POST['dokan_nonce'], 'account_migration')) { $user = get_userdata(get_current_user_id()); $errors = array(); $checks = array('fname' => __('Enter your first name', 'dokan'), 'lname' => __('Enter your last name', 'dokan'), 'shopname' => __('Enter your shop name', 'dokan'), 'address' => __('Enter your shop address', 'dokan'), 'phone' => __('Enter your phone number', 'dokan')); foreach ($checks as $field => $error) { if (empty($_POST[$field])) { $errors[] = $error; } } if (!$errors) { dokan_user_update_to_seller($user, $_POST); wp_redirect(dokan_get_page_url('myaccount', 'dokan')); } } }
function dokan_get_dashboard_nav() { $urls = array('dashboard' => array('title' => __('Dashboard', 'dokan'), 'icon' => '<i class="icon-dashboard"></i>', 'url' => dokan_get_page_url('dashboard')), 'product' => array('title' => __('Products', 'dokan'), 'icon' => '<i class="icon-briefcase"></i>', 'url' => dokan_get_page_url('products')), 'order' => array('title' => __('Orders', 'dokan'), 'icon' => '<i class="icon-basket"></i>', 'url' => dokan_get_page_url('orders')), 'coupon' => array('title' => __('Coupons', 'dokan'), 'icon' => '<i class="icon-gift"></i>', 'url' => dokan_get_page_url('coupons')), 'report' => array('title' => __('Reports', 'dokan'), 'icon' => '<i class="icon-stats"></i>', 'url' => dokan_get_page_url('reports')), 'reviews' => array('title' => __('Reviews', 'dokan'), 'icon' => '<i class="icon-bubbles"></i>', 'url' => dokan_get_page_url('reviews')), 'withdraw' => array('title' => __('Withdraw', 'dokan'), 'icon' => '<i class="icon-upload"></i>', 'url' => dokan_get_page_url('withdraw')), 'settings' => array('title' => __('Settings', 'dokan'), 'icon' => '<i class="icon-cog"></i>', 'url' => dokan_get_page_url('settings'))); return apply_filters('dokan_get_dashboard_nav', $urls); }
<article id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <div class="product-listing-top clearfix"> <?php dokan_product_listing_status_filter(); ?> <span class="col-md-3"> <a href="<?php echo dokan_get_page_url('new_product'); ?> " class="btn btn-large btn-theme pull-right"><i class="fa fa-briefcase"> </i> <?php _e('Add new product', 'dokan'); ?> </a> </span> </div> <?php dokan_product_dashboard_errors(); ?> <table class="table table-striped product-listing-table"> <thead> <tr>
/** * Redirect users from standard WordPress register page to woocommerce * my account page * * @global string $action */ function dokan_redirect_to_register() { global $action; if ($action == 'register') { wp_redirect(dokan_get_page_url('myaccount', 'woocommerce')); exit; } }
</a></li> </ul> </li> <li><?php wp_loginout(home_url()); ?> </li> <?php } else { ?> <li><a href="<?php echo dokan_get_page_url('myaccount', 'woocommerce'); ?> "><?php _e('Log in', 'dokan'); ?> </a></li> <li><a href="<?php echo dokan_get_page_url('myaccount', 'woocommerce'); ?> "><?php _e('Sign Up', 'dokan'); ?> </a></li> <?php } ?> </ul>