Ejemplo n.º 1
0
 /**
  * Bulk action handler
  *
  * @return void admin
  */
 function bulk_action_handler()
 {
     if (!current_user_can('manage_woocommerce')) {
         return;
     }
     if (!isset($_POST['dokan_withdraw_bulk'])) {
         return;
     }
     $bulk_action = $_POST['dokan_withdraw_bulk'];
     if (!isset($_POST['id'])) {
         return;
     }
     //if id empty then empty value return
     if (!is_array($_POST['id']) && !count($_POST['id'])) {
         return;
     }
     $withdraw_ids = implode("','", $_POST['id']);
     $status = $_POST['status_page'];
     switch ($bulk_action) {
         case 'paypal':
             $this->generate_csv($withdraw_ids);
             break;
         case 'delete':
             foreach ($_POST['id'] as $withdraw_id) {
                 $this->delete_withdraw($withdraw_id);
             }
             wp_redirect(admin_url('admin.php?page=dokan-withdraw&message=trashed&status=' . $status));
             die;
             break;
         case 'cancel':
             foreach ($_POST['id'] as $key => $withdraw_id) {
                 $user_id = $_POST['user_id'][$key];
                 $amount = $_POST['amount'][$key];
                 $method = $_POST['method'][$key];
                 $note = $_POST['note'][$key];
                 Dokan_Email::init()->withdraw_request_cancel($user_id, $amount, $method, $note);
                 $this->update_status($withdraw_id, $user_id, 2);
             }
             wp_redirect(admin_url('admin.php?page=dokan-withdraw&message=cancelled&status=' . $status));
             die;
             break;
         case 'approve':
             foreach ($_POST['id'] as $key => $withdraw_id) {
                 $user_id = $_POST['user_id'][$key];
                 $amount = $_POST['amount'][$key];
                 $method = $_POST['method'][$key];
                 Dokan_Email::init()->withdraw_request_approve($user_id, $amount, $method);
                 $this->update_status($withdraw_id, $user_id, 1);
             }
             wp_redirect(admin_url('admin.php?page=dokan-withdraw&message=approved&status=' . $status));
             break;
         case 'pending':
             foreach ($_POST['id'] as $key => $withdraw_id) {
                 $this->update_status($withdraw_id, $_POST['user_id'][$key], 0);
             }
             wp_redirect(admin_url('admin.php?page=dokan-withdraw&message=pending&status=' . $status));
             break;
     }
 }
Ejemplo n.º 2
0
/**
 * Send notification to the users when a product is published by seller
 *
 * @param WP_Post $post
 * @return void
 */
function dokan_send_notification_to_users($post)
{
    $prefix = FARMTOYOU_META_PREFIX;
    if ($post->post_type != 'product') {
        return;
    }
    $seller = get_user_by('id', $post->post_author);
    $product = get_product($post->ID);
    $dokan_email = new Dokan_Email();
    $args = array('post_type' => FARMTOYOU_NEWSLETTER_POST_TYPE, 'post_status' => 'active', 'posts_per_page' => '-1', 'meta_query' => array(array('key' => $prefix . 'post_author', 'value' => $seller->ID)));
    //get newsletter data from database
    $all_newsletter = get_posts($args);
    foreach ($all_newsletter as $value) {
        $category = wp_get_post_terms($product->id, 'product_cat', array('fields' => 'names'));
        $category_name = $category ? reset($category) : 'N/A';
        $user_id = get_post_meta($value->ID, $prefix . 'curr_user_id', true);
        $user_info = get_userdata($user_id);
        $first_name = $user_info->first_name;
        $last_name = $user_info->last_name;
        $param = array('vendor_id' => base64_encode($seller->ID), 'user_id' => base64_encode($user_id), 'status' => base64_encode('pending'));
        $unsubscribe_link = add_query_arg($param, site_url());
        $users_email = get_post_meta($value->ID, $prefix . 'post_title', true);
        $body = "Hello {$first_name} {$last_name}," . "\r\n\n";
        $body .= "A new product has been submitted to site (" . home_url() . ")\r\n\n";
        $body .= "Summary of the product:" . "\r\n";
        $body .= "------------------------" . "\r\n\n";
        $body .= "Title: " . $product->get_title() . "\r\n";
        $body .= "Price: " . $dokan_email->currency_symbol($product->get_price()) . "\r\n";
        $body .= "Seller: " . $seller->display_name . " (" . dokan_get_store_url($seller->ID) . ")\r\n";
        $body .= "Category: " . $category_name . "\r\n\n";
        $body .= "Currently you are active user of site. <a href='" . $unsubscribe_link . "'>Click here to unsubscribe</a>";
        $subject = sprintf(__('[%s] New Product Added', 'dokan'), $dokan_email->get_from_name());
        $headers = array('Content-Type: text/html; charset=UTF-8');
        $dokan_email->send($users_email, $subject, nl2br($body), $headers);
    }
}
Ejemplo n.º 3
0
 /**
  *  Handle withdraw action via ajax
  *  
  *  @return json success|error|data
  */
 function handle_withdraw_action()
 {
     parse_str($_POST['formData'], $postdata);
     if (!wp_verify_nonce($postdata['dokan_withdraw_admin_bulk_action_nonce'], 'dokan_withdraw_admin_bulk_action')) {
         wp_send_json_error();
     }
     $withdraw = Dokan_Template_Withdraw::init();
     $bulk_action = $_POST['status'];
     $status = $postdata['status_page'];
     $withdraw_id = $_POST['withdraw_id'];
     switch ($bulk_action) {
         case 'delete':
             $withdraw->delete_withdraw($withdraw_id);
             $url = admin_url('admin.php?page=dokan-withdraw&message=trashed&status=' . $status);
             wp_send_json_success(array('url' => $url));
             break;
         case 'cancel':
             $user_id = $postdata['user_id'][$withdraw_id];
             $amount = $postdata['amount'][$withdraw_id];
             $method = $postdata['method'][$withdraw_id];
             $note = $postdata['note'][$withdraw_id];
             Dokan_Email::init()->withdraw_request_cancel($user_id, $amount, $method, $note);
             $withdraw->update_status($withdraw_id, $user_id, 2);
             $url = admin_url('admin.php?page=dokan-withdraw&message=cancelled&status=' . $status);
             wp_send_json_success(array('url' => $url));
             break;
         case 'approve':
             $user_id = $postdata['user_id'][$withdraw_id];
             $amount = $postdata['amount'][$withdraw_id];
             $method = $postdata['method'][$withdraw_id];
             Dokan_Email::init()->withdraw_request_approve($user_id, $amount, $method);
             $withdraw->update_status($withdraw_id, $user_id, 1);
             $url = admin_url('admin.php?page=dokan-withdraw&message=approved&status=' . $status);
             wp_send_json_success(array('url' => $url));
             break;
         case 'pending':
             $withdraw->update_status($withdraw_id, $postdata['user_id'][$withdraw_id], 0);
             $url = admin_url('admin.php?page=dokan-withdraw&message=pending&status=' . $status);
             wp_send_json_success(array('url' => $url));
             break;
     }
 }
Ejemplo n.º 4
0
 /**
  * Insert withdraw info
  *
  * @return void
  */
 function insert_withdraw_info()
 {
     global $current_user, $wpdb;
     $amount = floatval($_POST['witdraw_amount']);
     $method = $_POST['withdraw_method'];
     $data_info = array('user_id' => $current_user->ID, 'amount' => $amount, 'status' => 0, 'method' => $method, 'ip' => dokan_get_client_ip(), 'notes' => '');
     $update = $this->insert_withdraw($data_info);
     Dokan_Email::init()->new_withdraw_request($current_user, $amount, $method);
     wp_redirect(add_query_arg(array('message' => 'request_success'), dokan_get_navigation_url('withdraw')));
 }
Ejemplo n.º 5
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);
}
Ejemplo n.º 6
0
 /**
  * Handle all the form POST submit
  *
  * @return void
  */
 function handle_all_submit()
 {
     if (!is_user_logged_in()) {
         return;
     }
     if (!dokan_is_user_seller(get_current_user_id())) {
         return;
     }
     $errors = array();
     self::$product_cat = -1;
     self::$post_content = __('Details of your product ...', 'dokan');
     if (!$_POST) {
         return;
     }
     if (isset($_POST['dokan_add_product']) && wp_verify_nonce($_POST['dokan_add_new_product_nonce'], 'dokan_add_new_product')) {
         $post_title = trim($_POST['post_title']);
         $post_content = trim($_POST['post_content']);
         $post_excerpt = isset($_POST['post_excerpt']) ? trim($_POST['post_excerpt']) : '';
         $price = floatval($_POST['_regular_price']);
         $featured_image = absint($_POST['feat_image_id']);
         $delivery_policy = trim($_POST['_delivery_policy']);
         $return_policy = trim($_POST['_return_policy']);
         $warranty_policy = trim($_POST['_warranty_policy']);
         $seller_policy = trim($_POST['_seller_policy']);
         if (empty($post_title)) {
             $errors[] = __('Please enter product title', 'dokan');
         }
         if (dokan_get_option('product_category_style', 'dokan_selling', 'single') == 'single') {
             $product_cat = intval($_POST['product_cat']);
             if ($product_cat < 0) {
                 $errors[] = __('Please select a category', 'dokan');
             }
         } else {
             if (!isset($_POST['product_cat']) && empty($_POST['product_cat'])) {
                 $errors[] = __('Please select AT LEAST ONE category', 'dokan');
             }
         }
         if (isset($_POST['dokan_product_id']) && empty($_POST['dokan_product_id'])) {
             self::$errors = apply_filters('dokan_can_add_product', $errors);
         } else {
             self::$errors = apply_filters('dokan_can_edit_product', $errors);
         }
         if (!self::$errors) {
             if (isset($_POST['dokan_product_id']) && empty($_POST['dokan_product_id'])) {
                 $product_status = dokan_get_new_post_status();
                 $post_data = apply_filters('dokan_insert_product_post_data', array('post_type' => 'product', 'post_status' => $product_status, 'post_title' => $post_title, 'post_content' => $post_content, 'post_excerpt' => $post_excerpt));
                 $product_id = wp_insert_post($post_data);
             } else {
                 $post_id = (int) $_POST['dokan_product_id'];
                 $product_info = apply_filters('dokan_update_product_post_data', array('ID' => $post_id, 'post_title' => sanitize_text_field($_POST['post_title']), 'post_content' => $_POST['post_content'], 'post_excerpt' => $_POST['post_excerpt'], 'post_status' => isset($_POST['post_status']) ? $_POST['post_status'] : 'pending', 'comment_status' => isset($_POST['_enable_reviews']) ? 'open' : 'closed'));
                 $product_id = wp_update_post($product_info);
             }
             if ($product_id) {
                 /** set images **/
                 if ($featured_image) {
                     set_post_thumbnail($product_id, $featured_image);
                 }
                 if (isset($_POST['product_tag']) && !empty($_POST['product_tag'])) {
                     $tags_ids = array_map('intval', (array) $_POST['product_tag']);
                     wp_set_object_terms($product_id, $tags_ids, 'product_tag');
                 }
                 /** set product category * */
                 if (dokan_get_option('product_category_style', 'dokan_selling', 'single') == 'single') {
                     wp_set_object_terms($product_id, (int) $_POST['product_cat'], 'product_cat');
                 } else {
                     if (isset($_POST['product_cat']) && !empty($_POST['product_cat'])) {
                         $cat_ids = array_map('intval', (array) $_POST['product_cat']);
                         wp_set_object_terms($product_id, $cat_ids, 'product_cat');
                     }
                 }
                 /** Set Product type by default simple */
                 if (isset($_POST['_create_variation']) && $_POST['_create_variation'] == 'yes') {
                     wp_set_object_terms($product_id, 'variable', 'product_type');
                 } else {
                     wp_set_object_terms($product_id, 'simple', 'product_type');
                 }
                 update_post_meta($product_id, '_regular_price', $price);
                 update_post_meta($product_id, '_sale_price', '');
                 update_post_meta($product_id, '_price', $price);
                 update_post_meta($product_id, '_visibility', 'visible');
                 update_post_meta($product_id, '_delivery_policy', $delivery_policy);
                 update_post_meta($product_id, '_return_policy', $return_policy);
                 update_post_meta($product_id, '_warranty_policy', $warranty_policy);
                 update_post_meta($product_id, '_seller_policy', $seller_policy);
                 dokan_new_process_product_meta($product_id);
                 if (isset($_POST['dokan_product_id']) && empty($_POST['dokan_product_id'])) {
                     do_action('dokan_new_product_added', $product_id, $post_data);
                 }
                 if (isset($_POST['dokan_product_id']) && empty($_POST['dokan_product_id'])) {
                     if (dokan_get_option('product_add_mail', 'dokan_general', 'on') == 'on') {
                         Dokan_Email::init()->new_product_added($product_id, $product_status);
                     }
                 }
                 wp_redirect(add_query_arg(array('message' => 'success'), dokan_edit_product_url($product_id)));
                 exit;
             }
         }
     }
     if (isset($_POST['add_product']) && wp_verify_nonce($_POST['dokan_add_new_product_nonce'], 'dokan_add_new_product')) {
         $post_title = trim($_POST['post_title']);
         $post_content = trim($_POST['post_content']);
         $post_excerpt = trim($_POST['post_excerpt']);
         $price = floatval($_POST['price']);
         $featured_image = absint($_POST['feat_image_id']);
         if (empty($post_title)) {
             $errors[] = __('Please enter product title', 'dokan');
         }
         if (dokan_get_option('product_category_style', 'dokan_selling', 'single') == 'single') {
             $product_cat = intval($_POST['product_cat']);
             if ($product_cat < 0) {
                 $errors[] = __('Please select a category', 'dokan');
             }
         } else {
             if (!isset($_POST['product_cat']) && empty($_POST['product_cat'])) {
                 $errors[] = __('Please select AT LEAST ONE category', 'dokan');
             }
         }
         self::$errors = apply_filters('dokan_can_add_product', $errors);
         if (!self::$errors) {
             $product_status = dokan_get_new_post_status();
             $post_data = apply_filters('dokan_insert_product_post_data', array('post_type' => 'product', 'post_status' => $product_status, 'post_title' => $post_title, 'post_content' => $post_content, 'post_excerpt' => $post_excerpt));
             $product_id = wp_insert_post($post_data);
             if ($product_id) {
                 /** set images **/
                 if ($featured_image) {
                     set_post_thumbnail($product_id, $featured_image);
                 }
                 if (isset($_POST['product_tag']) && !empty($_POST['product_tag'])) {
                     $tags_ids = array_map('intval', (array) $_POST['product_tag']);
                     wp_set_object_terms($product_id, $tags_ids, 'product_tag');
                 }
                 /** set product category * */
                 if (dokan_get_option('product_category_style', 'dokan_selling', 'single') == 'single') {
                     wp_set_object_terms($product_id, (int) $_POST['product_cat'], 'product_cat');
                 } else {
                     if (isset($_POST['product_cat']) && !empty($_POST['product_cat'])) {
                         $cat_ids = array_map('intval', (array) $_POST['product_cat']);
                         wp_set_object_terms($product_id, $cat_ids, 'product_cat');
                     }
                 }
                 /** Set Product type by default simple */
                 wp_set_object_terms($product_id, 'simple', 'product_type');
                 update_post_meta($product_id, '_regular_price', $price);
                 update_post_meta($product_id, '_sale_price', '');
                 update_post_meta($product_id, '_price', $price);
                 update_post_meta($product_id, '_visibility', 'visible');
                 do_action('dokan_new_product_added', $product_id, $post_data);
                 if (dokan_get_option('product_add_mail', 'dokan_general', 'on') == 'on') {
                     Dokan_Email::init()->new_product_added($product_id, $product_status);
                 }
                 wp_redirect(dokan_edit_product_url($product_id));
                 exit;
             }
         }
     }
     if (isset($_GET['product_id'])) {
         $post_id = intval($_GET['product_id']);
     } else {
         global $post, $product;
         if (!empty($post)) {
             $post_id = $post->ID;
         }
     }
     if (isset($_POST['update_product']) && wp_verify_nonce($_POST['dokan_edit_product_nonce'], 'dokan_edit_product')) {
         $post_title = trim($_POST['post_title']);
         if (empty($post_title)) {
             $errors[] = __('Please enter product title', 'dokan');
         }
         if (dokan_get_option('product_category_style', 'dokan_selling', 'single') == 'single') {
             $product_cat = intval($_POST['product_cat']);
             if ($product_cat < 0) {
                 $errors[] = __('Please select a category', 'dokan');
             }
         } else {
             if (!isset($_POST['product_cat']) && empty($_POST['product_cat'])) {
                 $errors[] = __('Please select AT LEAST ONE category', 'dokan');
             }
         }
         self::$errors = apply_filters('dokan_can_edit_product', $errors);
         if (!self::$errors) {
             $product_info = array('ID' => $post_id, 'post_title' => sanitize_text_field($_POST['post_title']), 'post_content' => $_POST['post_content'], 'post_excerpt' => $_POST['post_excerpt'], 'post_status' => isset($_POST['post_status']) ? $_POST['post_status'] : 'pending', 'comment_status' => isset($_POST['_enable_reviews']) ? 'open' : 'closed');
             wp_update_post($product_info);
             /** Set Product tags */
             if (isset($_POST['product_tag'])) {
                 $tags_ids = array_map('intval', (array) $_POST['product_tag']);
             } else {
                 $tags_ids = array();
             }
             wp_set_object_terms($post_id, $tags_ids, 'product_tag');
             /** set product category * */
             if (dokan_get_option('product_category_style', 'dokan_selling', 'single') == 'single') {
                 wp_set_object_terms($post_id, (int) $_POST['product_cat'], 'product_cat');
             } else {
                 if (isset($_POST['product_cat']) && !empty($_POST['product_cat'])) {
                     $cat_ids = array_map('intval', (array) $_POST['product_cat']);
                     wp_set_object_terms($post_id, $cat_ids, 'product_cat');
                 }
             }
             wp_set_object_terms($post_id, 'simple', 'product_type');
             /**  Process all variation products meta */
             dokan_process_product_meta($post_id);
             /** set images **/
             $featured_image = absint($_POST['feat_image_id']);
             if ($featured_image) {
                 set_post_thumbnail($post_id, $featured_image);
             }
             $edit_url = dokan_edit_product_url($post_id);
             wp_redirect(add_query_arg(array('message' => 'success'), $edit_url));
             exit;
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * Init all the classes
  *
  * @return void
  */
 function init_classes()
 {
     if (is_admin()) {
         new Dokan_Admin_User_Profile();
     } else {
         new Dokan_Pageviews();
     }
     new Dokan_Rewrites();
     Dokan_Email::init();
     Dokan_Template_Shortcodes::init();
 }
Ejemplo n.º 8
0
 function handle_all_submit()
 {
     $errors = array();
     self::$product_cat = -1;
     //self::$post_content = __( 'Details about your product...', 'dokan' );
     self::$post_content = __('', 'dokan');
     if (!$_POST) {
         return;
     }
     if (isset($_POST['add_product'])) {
         $post_title = trim($_POST['post_title']);
         $post_content = trim($_POST['post_content']);
         $post_excerpt = trim($_POST['post_excerpt']);
         $mrp = floatval($_POST['mrp']);
         $price = floatval($_POST['price']);
         $product_cat = intval($_POST['product_cat']);
         $featured_image = absint($_POST['feat_image_id']);
         if (empty($post_title)) {
             $errors[] = __('Please enter product title', 'dokan');
         }
         if ($product_cat < 0) {
             $errors[] = __('Please select a category', 'dokan');
         }
         self::$errors = apply_filters('dokan_can_add_product', $errors);
         if (!self::$errors) {
             $product_status = dokan_get_new_post_status();
             $post_data = apply_filters('dokan_insert_product_post_data', array('post_type' => 'product', 'post_status' => $product_status, 'post_title' => $post_title, 'post_content' => $post_content, 'post_excerpt' => $post_excerpt));
             $product_id = wp_insert_post($post_data);
             if ($product_id) {
                 /** set images **/
                 if ($featured_image) {
                     set_post_thumbnail($product_id, $featured_image);
                 }
                 /** set product category * */
                 wp_set_object_terms($product_id, (int) $_POST['product_cat'], 'product_cat');
                 wp_set_object_terms($product_id, 'simple', 'product_type');
                 update_post_meta($product_id, '_regular_price', $price);
                 update_post_meta($product_id, '_list_price_mrp', $mrp);
                 update_post_meta($product_id, '_sale_price', '');
                 update_post_meta($product_id, '_price', $price);
                 update_post_meta($product_id, '_visibility', 'visible');
                 $sell = array('sell_in' => '', 'state' => '', 'city' => '');
                 update_post_meta($product_id, 'sell_in', $sell);
                 do_action('dokan_new_product_added', $product_id, $post_data);
                 Dokan_Email::init()->new_product_added($product_id, $product_status);
                 wp_redirect(dokan_edit_product_url($product_id));
             }
         }
     }
     if (isset($_GET['product_id'])) {
         $post_id = intval($_GET['product_id']);
     } else {
         global $post, $product;
         $post_id = $post->ID;
     }
     if (isset($_POST['update_product'])) {
         $product_info = array('ID' => $post_id, 'post_title' => sanitize_text_field($_POST['post_title']), 'post_content' => $_POST['post_content'], 'post_excerpt' => $_POST['post_excerpt'], 'post_status' => isset($_POST['post_status']) ? $_POST['post_status'] : 'pending', 'comment_status' => isset($_POST['_enable_reviews']) ? 'open' : 'closed');
         wp_update_post($product_info);
         /** set product category * */
         wp_set_object_terms($post_id, (int) $_POST['product_cat'], 'product_cat');
         wp_set_object_terms($post_id, 'simple', 'product_type');
         dokan_process_product_meta($post_id);
         /** set images **/
         $featured_image = absint($_POST['feat_image_id']);
         if ($featured_image) {
             set_post_thumbnail($post_id, $featured_image);
         }
         $edit_url = dokan_edit_product_url($post_id);
         wp_redirect(add_query_arg(array('message' => 'success'), $edit_url));
     }
     dokan_delete_product_handler();
     // Coupon functionality
     $dokan_template_coupons = Dokan_Template_Coupons::init();
     self::$validated = $dokan_template_coupons->validate();
     if (!is_wp_error(self::$validated)) {
         $dokan_template_coupons->coupons_create();
     }
     $dokan_template_coupons->coupun_delete();
     // Withdraw functionality
     $dokan_withdraw = Dokan_Template_Withdraw::init();
     self::$validate = $dokan_withdraw->validate();
     if (self::$validate !== false && !is_wp_error(self::$validate)) {
         $dokan_withdraw->insert_withdraw_info();
     }
     $dokan_withdraw->cancel_pending();
 }
Ejemplo n.º 9
0
        $post_data = array('post_type' => 'product', 'post_status' => $product_status, 'post_title' => $post_title, 'post_content' => $post_content, 'post_excerpt' => $post_excerpt);
        $product_id = wp_insert_post($post_data);
        if ($product_id) {
            /** set images **/
            if ($featured_image) {
                set_post_thumbnail($product_id, $featured_image);
            }
            /** set product category * */
            wp_set_object_terms($product_id, (int) $_POST['product_cat'], 'product_cat');
            wp_set_object_terms($product_id, 'simple', 'product_type');
            update_post_meta($product_id, '_regular_price', $price);
            update_post_meta($product_id, '_sale_price', '');
            update_post_meta($product_id, '_price', $price);
            update_post_meta($product_id, '_visibility', 'visible');
            do_action('dokan_new_product_added', $product_id, $post_data);
            Dokan_Email::init()->new_product_added($product_id, $product_status);
            wp_redirect(dokan_edit_product_url($product_id));
        }
    }
}
get_header();
dokan_frontend_dashboard_scripts();
?>

<?php 
dokan_get_template(dirname(__FILE__) . '/dashboard-nav.php', array('active_menu' => 'product'));
?>

<div id="primary" class="content-area col-md-9">
    <div id="content" class="site-content" role="main">
Ejemplo n.º 10
0
/**
 * Send notification to the seller once a product is published from pending
 * 
 * @param WP_Post $post
 * @return void
 */
function dokan_send_notification_on_product_publish($post)
{
    if ($post->post_type != 'product') {
        return;
    }
    $seller = get_user_by('id', $post->post_author);
    Dokan_Email::init()->product_published($post, $seller);
}
Ejemplo n.º 11
0
 function handle_all_submit()
 {
     if (!is_user_logged_in()) {
         return;
     }
     if (!dokan_is_user_seller(get_current_user_id())) {
         return;
     }
     $errors = array();
     self::$product_cat = -1;
     self::$post_content = __('Details about your product...', 'dokan');
     if (!$_POST) {
         return;
     }
     if (isset($_POST['add_product']) && wp_verify_nonce($_POST['dokan_add_new_product_nonce'], 'dokan_add_new_product')) {
         $post_title = trim($_POST['post_title']);
         $post_content = trim($_POST['post_content']);
         $post_excerpt = trim($_POST['post_excerpt']);
         $price = floatval($_POST['price']);
         $product_cat = intval($_POST['product_cat']);
         $featured_image = absint($_POST['feat_image_id']);
         if (empty($post_title)) {
             $errors[] = __('Please enter product title', 'dokan');
         }
         if ($product_cat < 0) {
             $errors[] = __('Please select a category', 'dokan');
         }
         self::$errors = apply_filters('dokan_can_add_product', $errors);
         if (!self::$errors) {
             $post_data = apply_filters('dokan_insert_product_post_data', array('post_type' => 'product', 'post_status' => 'publish', 'post_title' => $post_title, 'post_content' => $post_content, 'post_excerpt' => $post_excerpt));
             $product_id = wp_insert_post($post_data);
             if ($product_id) {
                 /** set images **/
                 if ($featured_image) {
                     set_post_thumbnail($product_id, $featured_image);
                 }
                 /** set product category * */
                 wp_set_object_terms($product_id, (int) $_POST['product_cat'], 'product_cat');
                 wp_set_object_terms($product_id, 'simple', 'product_type');
                 update_post_meta($product_id, '_regular_price', $price);
                 update_post_meta($product_id, '_sale_price', '');
                 update_post_meta($product_id, '_price', $price);
                 update_post_meta($product_id, '_visibility', 'visible');
                 do_action('dokan_new_product_added', $product_id, $post_data);
                 Dokan_Email::init()->new_product_added($product_id, 'publish');
                 wp_redirect(dokan_edit_product_url($product_id));
                 exit;
             }
         }
     }
     if (isset($_GET['product_id'])) {
         $post_id = intval($_GET['product_id']);
     } else {
         global $post, $product;
         if (!empty($post)) {
             $post_id = $post->ID;
         }
     }
     if (isset($_POST['update_product']) && wp_verify_nonce($_POST['dokan_edit_product_nonce'], 'dokan_edit_product')) {
         $product_info = array('ID' => $post_id, 'post_title' => sanitize_text_field($_POST['post_title']), 'post_content' => $_POST['post_content'], 'post_excerpt' => $_POST['post_excerpt'], 'post_status' => isset($_POST['post_status']) ? $_POST['post_status'] : 'pending', 'comment_status' => isset($_POST['_enable_reviews']) ? 'open' : 'closed');
         wp_update_post($product_info);
         /** set product category * */
         wp_set_object_terms($post_id, (int) $_POST['product_cat'], 'product_cat');
         wp_set_object_terms($post_id, 'simple', 'product_type');
         dokan_process_product_meta($post_id);
         /** set images **/
         $featured_image = absint($_POST['feat_image_id']);
         if ($featured_image) {
             set_post_thumbnail($post_id, $featured_image);
         }
         $edit_url = dokan_edit_product_url($post_id);
         wp_redirect(add_query_arg(array('message' => 'success'), $edit_url));
         exit;
     }
 }
Ejemplo n.º 12
0
 /**
  * Init all the classes
  *
  * @return void
  */
 function init_classes()
 {
     if (is_admin()) {
         Dokan_Slider::init();
         new Dokan_Admin_User_Profile();
         new Dokan_Update();
     } else {
         new Dokan_Pageviews();
     }
     new Dokan_Rewrites();
     Dokan_Email::init();
 }
Ejemplo n.º 13
0
function adding_extra_reg_fields($user_id)
{
    extract($_POST);
    $dokan_settings = array('store_name' => strip_tags($_POST['shopname']), 'social' => array(), 'payment' => array(), 'phone' => $_POST['phone'], 'show_email' => 'no', 'address' => strip_tags($_POST['address']), 'location' => '', 'find_address' => '', 'dokan_category' => '', 'banner' => 0);
    update_user_meta($user_id, 'dokan_profile_settings', $dokan_settings);
    update_user_meta($user_id, 'dokan_publishing', 'no');
    update_user_meta($user_id, 'dokan_enable_selling', 'no');
    update_user_meta($user_id, 'dokan_seller_percentage', 0);
    update_user_meta($user_id, 'sw_capabilities', array('seller' => 1));
    update_user_meta($user_id, 'nickname', sanitize_title($_POST['shopname']));
    update_user_meta($user_id, 'first_name', $_POST['fname']);
    update_user_meta($user_id, 'last_name', $_POST['lname']);
    update_user_meta($user_id, 'billing_first_name', $_POST['fname']);
    update_user_meta($user_id, 'billing_last_name', $_POST['lname']);
    update_user_meta($user_id, 'shipping_first_name', $_POST['fname']);
    update_user_meta($user_id, 'shipping_last_name', $_POST['lname']);
    //update_user_meta($user_id, 'billing_postcode',$_POST['billing_postcode']);
    //update_user_meta($user_id, 'billing_address_1',$_POST['billing_address_1']);
    //update_user_meta($user_id, 'billing_address_2',$_POST['billing_address_2']);
    update_user_meta($user_id, 'billing_city', $_POST['billing_city']);
    update_user_meta($user_id, 'billing_state', $_POST['billing_state']);
    update_user_meta($user_id, 'billing_phone', $_POST['phone']);
    Dokan_Email::init()->new_seller_registered_mail($user_id);
}
Ejemplo n.º 14
0
 /**
  * Init all the classes
  *
  * @return void
  */
 function init_classes()
 {
     if (is_admin()) {
         new Dokan_Admin_User_Profile();
         Dokan_Admin_Ajax::init();
         new Dokan_Announcement();
         new Dokan_Update();
         new Dokan_Upgrade();
     } else {
         new Dokan_Pageviews();
     }
     new Dokan_Rewrites();
     Dokan_Email::init();
     Dokan_Template_Shortcodes::init();
     Dokan_Template_Shipping::init();
 }
Ejemplo n.º 15
0
 /**
  * Init all the classes
  *
  * @return void
  */
 function init_classes()
 {
     if (is_admin()) {
         new Dokan_Admin_User_Profile();
         Dokan_Admin_Ajax::init();
         new Dokan_Upgrade();
     } else {
         new Dokan_Pageviews();
     }
     new Dokan_Rewrites();
     Dokan_Email::init();
     if (is_user_logged_in()) {
         Dokan_Template_Main::init();
         Dokan_Template_Dashboard::init();
         Dokan_Template_Products::init();
         Dokan_Template_Orders::init();
         Dokan_Template_Withdraw::init();
         Dokan_Template_Shortcodes::init();
         Dokan_Template_Settings::init();
     }
 }
Ejemplo n.º 16
0
/**
 * Adds default dokan store settings when a new seller registers
 *
 * @param int $user_id
 * @param array $data
 * @return void
 */
function dokan_on_create_seller($user_id, $data)
{
    if ($data['role'] != 'seller') {
        return;
    }
    $dokan_settings = array('store_name' => strip_tags($_POST['shopname']), 'social' => array(), 'payment' => array(), 'phone' => $_POST['phone'], 'show_email' => 'no', 'address' => strip_tags($_POST['address']), 'location' => '', 'dokan_category' => '', 'banner' => 0);
    update_user_meta($user_id, 'dokan_profile_settings', $dokan_settings);
    Dokan_Email::init()->new_seller_registered_mail($user_id);
}
Ejemplo n.º 17
0
 /**
  * Seller store page email contact form handler
  *
  * Catches the form submission from store page
  */
 function contact_seller()
 {
     $posted = $_POST;
     check_ajax_referer('dokan_contact_seller');
     // print_r($posted);
     $seller = get_user_by('id', (int) $posted['seller_id']);
     if (!$seller) {
         $message = sprintf('<div class="alert alert-success">%s</div>', __('Something went wrong!', 'dokan'));
         wp_send_json_error($message);
     }
     $contact_name = trim(strip_tags($posted['name']));
     Dokan_Email::init()->contact_seller($seller->user_email, $contact_name, $posted['email'], $posted['message']);
     $success = sprintf('<div class="alert alert-success">%s</div>', __('Email sent successfully!', 'dokan'));
     wp_send_json_success($success);
     exit;
 }