Пример #1
0
 /**
  * chop url check
  */
 function shop_url_check()
 {
     global $user_ID;
     if (!wp_verify_nonce($_POST['_nonce'], 'dokan_reviews')) {
         wp_send_json_error(array('type' => 'nonce', 'message' => __('Are you cheating?', 'dokan')));
     }
     $url_slug = $_POST['url_slug'];
     $check = true;
     $user = get_user_by('slug', $url_slug);
     if ($user != '') {
         $check = false;
     }
     // check if a customer wants to migrate, his username should be available
     if (is_user_logged_in() && dokan_is_user_customer($user_ID)) {
         $current_user = wp_get_current_user();
         if ($current_user->user_nicename == $user->user_nicename) {
             $check = true;
         }
     }
     echo $check;
 }
Пример #2
0
function dokan_account_migration_button()
{
    $user = wp_get_current_user();
    if (dokan_is_user_customer($user->ID)) {
        ?>
        <p>&nbsp;</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 
    }
}
Пример #3
0
 /**
  * Account migration template on my account
  *
  * @param string  $file path of the template
  * @return string
  */
 function account_migration_template($file)
 {
     if (get_query_var('account-migration') && dokan_is_user_customer(get_current_user_id())) {
         return dokan_locate_template('update-account.php');
     }
     return $file;
 }
Пример #4
0
/**
 * Adds default dokan store settings when a new seller registers
 *
 * @param int $user_id
 * @param array $data
 * @return void
 */
function dokan_user_update_to_seller($user, $data)
{
    if (!dokan_is_user_customer($user->ID)) {
        return;
    }
    $user_id = $user->ID;
    // Remove role
    $user->remove_role('customer');
    // Add role
    $user->add_role('seller');
    update_user_meta($user_id, 'first_name', $data['fname']);
    update_user_meta($user_id, 'last_name', $data['lname']);
    if (dokan_get_option('new_seller_enable_selling', 'dokan_selling', 'on') == 'off') {
        update_user_meta($user_id, 'dokan_enable_selling', 'no');
    } else {
        update_user_meta($user_id, 'dokan_enable_selling', 'yes');
    }
    $dokan_settings = array('store_name' => $data['shopname'], 'social' => array(), 'payment' => array(), 'phone' => $data['phone'], 'show_email' => 'no', 'address' => $data['address'], 'location' => '', 'find_address' => '', 'dokan_category' => '', 'banner' => 0);
    update_user_meta($user_id, 'dokan_profile_settings', $dokan_settings);
    $publishing = dokan_get_option('product_status', 'dokan_selling');
    $percentage = dokan_get_option('seller_percentage', 'dokan_selling');
    update_user_meta($user_id, 'dokan_publishing', $publishing);
    update_user_meta($user_id, 'dokan_seller_percentage', $percentage);
    Dokan_Email::init()->new_seller_registered_mail($user_id);
}
Пример #5
0
 /**
  * Account migration template on my account
  *
  * @param string  $file path of the template
  *
  * @return string
  */
 function account_migration_template($file)
 {
     if (get_query_var('account-migration') && dokan_is_user_customer(get_current_user_id()) && basename($file) == 'my-account.php') {
         $file = dokan_locate_template('global/update-account.php', '', '', true);
     }
     return $file;
 }