Exemple #1
0
 /**
  * Init ajax handlers
  *
  * @return void
  */
 function init_ajax()
 {
     //withdraw note
     $withdraw = Dokan_Template_Withdraw::init();
     add_action('wp_ajax_note', array($withdraw, 'note_update'));
     add_action('wp_ajax_withdraw_ajax_submission', array($withdraw, 'withdraw_ajax'));
     // reviews
     $reviews = Dokan_Template_reviews::init();
     add_action('wp_ajax_dokan_comment_status', array($reviews, 'ajax_comment_status'));
     add_action('wp_ajax_dokan_update_comment', array($reviews, 'ajax_update_comment'));
     //settings
     $settings = Dokan_Template_Settings::init();
     add_action('wp_ajax_dokan_settings', array($settings, 'ajax_settings'));
     add_action('wp_ajax_dokan-mark-order-complete', array($this, 'complete_order'));
     add_action('wp_ajax_dokan-mark-order-processing', array($this, 'process_order'));
     add_action('wp_ajax_dokan_grant_access_to_download', array($this, 'grant_access_to_download'));
     add_action('wp_ajax_dokan_change_status', array($this, 'change_order_status'));
     add_action('wp_ajax_dokan_contact_seller', array($this, 'contact_seller'));
     add_action('wp_ajax_dokan_add_variation', array($this, 'add_variation'));
     add_action('wp_ajax_dokan_link_all_variations', array($this, 'link_all_variations'));
     add_action('wp_ajax_dokan_save_attributes', array($this, 'save_attributes'));
     add_action('wp_ajax_dokan_toggle_seller', array($this, 'toggle_seller_status'));
     add_action('wp_ajax_nopriv_shop_url', array($this, 'shop_url_check'));
     add_filter('woocommerce_cart_item_name', array($this, 'seller_info_checkout'), 10, 2);
 }
Exemple #2
0
 function admin_init()
 {
     Dokan_Template_Withdraw::init()->bulk_action_handler();
     //set the settings
     $this->settings_api->set_sections($this->get_settings_sections());
     $this->settings_api->set_fields($this->get_settings_fields());
     //initialize settings
     $this->settings_api->admin_init();
 }
Exemple #3
0
 /**
  * Init ajax handlers
  *
  * @return void
  */
 function init_ajax()
 {
     //withdraw note
     $withdraw = Dokan_Template_Withdraw::init();
     add_action('wp_ajax_note', array($withdraw, 'note_update'));
     add_action('wp_ajax_withdraw_ajax_submission', array($withdraw, 'withdraw_ajax'));
     // reviews
     $reviews = Dokan_Template_reviews::init();
     add_action('wp_ajax_dokan_comment_status', array($reviews, 'ajax_comment_status'));
     add_action('wp_ajax_dokan_update_comment', array($reviews, 'ajax_update_comment'));
     //settings
     $settings = Dokan_Template_Settings::init();
     add_action('wp_ajax_dokan_settings', array($settings, 'ajax_settings'));
     add_action('wp_ajax_dokan-mark-order-complete', array($this, 'complete_order'));
     add_action('wp_ajax_dokan-mark-order-processing', array($this, 'process_order'));
     add_action('wp_ajax_dokan_grant_access_to_download', array($this, 'grant_access_to_download'));
     add_action('wp_ajax_dokan_change_status', array($this, 'change_order_status'));
     add_action('wp_ajax_dokan_contact_seller', array($this, 'contact_seller'));
     add_action('wp_ajax_dokan_add_variation', array($this, 'add_variation'));
     add_action('wp_ajax_dokan_link_all_variations', array($this, 'link_all_variations'));
     add_action('wp_ajax_dokan_pre_define_attribute', array($this, 'dokan_pre_define_attribute'));
     add_action('wp_ajax_dokan_save_attributes', array($this, 'save_attributes'));
     add_action('wp_ajax_dokan_toggle_seller', array($this, 'toggle_seller_status'));
     add_action('wp_ajax_shop_url', array($this, 'shop_url_check'));
     add_action('wp_ajax_nopriv_shop_url', array($this, 'shop_url_check'));
     add_filter('woocommerce_cart_item_name', array($this, 'seller_info_checkout'), 10, 2);
     // Shipping ajax hanlding
     add_action('wp_ajax_dps_select_state_by_country', array($this, 'load_state_by_country'));
     add_action('wp_ajax_nopriv_dps_select_state_by_country', array($this, 'load_state_by_country'));
     // Announcement ajax handling
     add_action('wp_ajax_dokan_announcement_remove_row', array($this, 'remove_announcement'));
     add_action('wp_ajax_nopriv_dokan_announcement_remove_row', array($this, 'remove_announcement'));
     // shipping state ajax
     add_action('wp_ajax_nopriv_dokan_shipping_country_select', array($this, 'get_state_by_shipping_country'));
     add_action('wp_ajax_dokan_shipping_country_select', array($this, 'get_state_by_shipping_country'));
     // shipping calculation ajax
     add_action('wp_ajax_nopriv_dokan_shipping_calculator', array($this, 'get_calculated_shipping_cost'));
     add_action('wp_ajax_dokan_shipping_calculator', array($this, 'get_calculated_shipping_cost'));
     // Single product Design ajax
     add_action('wp_ajax_dokan_save_attributes_options', array($this, 'save_attributes_options'));
     add_action('wp_ajax_nopriv_dokan_save_attributes_options', array($this, 'save_attributes_options'));
     add_action('wp_ajax_dokan_save_variations_options', array($this, 'save_variations_options'));
     add_action('wp_ajax_nopriv_dokan_save_variations_options', array($this, 'save_variations_options'));
     add_action('wp_ajax_dokan_add_new_variations_options', array($this, 'add_new_variations_options'));
     add_action('wp_ajax_nopriv_dokan_add_new_variations_options', array($this, 'add_new_variations_options'));
     add_action('wp_ajax_dokan_remove_single_variation_item', array($this, 'remove_single_variation_item'));
     add_action('wp_ajax_nopriv_dokan_remove_single_variation_item', array($this, 'remove_single_variation_item'));
     add_action('wp_ajax_dokan_get_pre_attribute', array($this, 'add_predefined_attribute'));
     add_action('wp_ajax_nopriv_dokan_get_pre_attribute', array($this, 'add_predefined_attribute'));
 }
Exemple #4
0
 /**
  * Init ajax handlers
  *
  * @return void
  */
 function init_ajax()
 {
     //withdraw note
     $withdraw = Dokan_Template_Withdraw::init();
     add_action('wp_ajax_withdraw_ajax_submission', array($withdraw, 'withdraw_ajax'));
     //settings
     $settings = Dokan_Template_Settings::init();
     add_action('wp_ajax_dokan_settings', array($settings, 'ajax_settings'));
     add_action('wp_ajax_dokan-mark-order-complete', array($this, 'complete_order'));
     add_action('wp_ajax_dokan-mark-order-processing', array($this, 'process_order'));
     add_action('wp_ajax_dokan_change_status', array($this, 'change_order_status'));
     add_action('wp_ajax_dokan_toggle_seller', array($this, 'toggle_seller_status'));
     add_action('wp_ajax_shop_url', array($this, 'shop_url_check'));
     add_action('wp_ajax_nopriv_shop_url', array($this, 'shop_url_check'));
     add_filter('woocommerce_cart_item_name', array($this, 'seller_info_checkout'), 10, 2);
 }
Exemple #5
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;
     }
 }
Exemple #6
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();
     }
 }
 /**
  * Handle Withdraw form submission
  *
  * @return void
  */
 function handle_withdraws()
 {
     // Withdraw functionality
     self::$validate = $this->validate();
     if (self::$validate !== false && !is_wp_error(self::$validate)) {
         $this->insert_withdraw_info();
     }
     $this->cancel_pending();
 }
 /**
  * Handle Withdraw form submission
  *
  * @return void
  */
 function handle_withdraws()
 {
     // 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();
 }
Exemple #9
0
<?php

$dokan_admin_withdraw = Dokan_Template_Withdraw::init();
$counts = dokan_get_withdraw_count();
$status = isset($_GET['status']) ? $_GET['status'] : 'pending';
?>
<div class="wrap">
    <h2><?php 
_e('Withdraw Requests', 'dokan');
?>
</h2>

    <ul class="subsubsub" style="float: none;">
        <li>
            <a href="admin.php?page=dokan-withdraw&amp;status=pending" <?php 
if ($status == 'pending') {
    echo 'class="current"';
}
?>
>
                <?php 
_e('Pending', 'dokan');
?>
 <span class="count">(<?php 
echo $counts['pending'];
?>
)</span>
            </a> |
        </li>
        <li>
            <a href="admin.php?page=dokan-withdraw&amp;status=completed" <?php 
 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();
 }