Пример #1
0
 /**
  * Adds proper hooks for output of meta tags
  *
  * @return void
  */
 function output_meta_tags()
 {
     if (!dokan_is_store_page()) {
         return;
     }
     if (dokan_get_option('store_seo', 'dokan_general') === 'off') {
         return;
     }
     $this->store_info = dokan_get_store_info(get_query_var('author'));
     if (class_exists('All_in_One_SEO_Pack')) {
         add_filter('aioseop_title', array($this, 'replace_title'), 500);
         add_filter('aioseop_keywords', array($this, 'replace_keywords'), 100);
         add_filter('aioseop_description', array($this, 'replace_desc'), 100);
         add_action('wp_head', array($this, 'print_social_tags'), 1);
     } elseif (class_exists('WPSEO_Frontend')) {
         add_filter('wp_title', array($this, 'replace_title'), 500);
         add_filter('wpseo_metakeywords', array($this, 'replace_keywords'));
         add_filter('wpseo_metadesc', array($this, 'replace_desc'));
         add_filter('wpseo_opengraph_title', array($this, 'replace_og_title'));
         add_filter('wpseo_opengraph_desc', array($this, 'replace_og_desc'));
         add_filter('wpseo_opengraph_image', array($this, 'replace_og_img'));
         add_action('wpseo_opengraph', array($this, 'print_og_img'), 20);
         add_filter('wpseo_twitter_title', array($this, 'replace_twitter_title'));
         add_filter('wpseo_twitter_description', array($this, 'replace_twitter_desc'));
         add_filter('wpseo_twitter_image', array($this, 'replace_twitter_img'));
         add_action('wpseo_twitter', array($this, 'print_twitter_img'), 20);
     } else {
         add_filter('wp_title', array($this, 'replace_title'), 500);
         add_action('wp_head', array($this, 'print_tags'), 1);
         add_action('wp_head', array($this, 'print_social_tags'), 1);
     }
 }
Пример #2
0
 /**
  * Render New Product Template
  *
  * @since 2.4
  *
  * @param  array $query_vars
  *
  * @return void
  */
 public function render_new_product_template($query_vars)
 {
     if (isset($query_vars['new-product'])) {
         if (dokan_get_option('product_style', 'dokan_selling', 'old') == 'old') {
             dokan_get_template_part('products/new-product', '', array('pro' => true));
         } else {
             dokan_get_template_part('products/new-product-single');
         }
     }
 }
Пример #3
0
 /**
  * Hook into the functions
  */
 public function __construct()
 {
     $this->custom_store_url = dokan_get_option('custom_store_url', 'dokan_selling', 'store');
     add_action('init', array($this, 'register_rule'));
     add_filter('template_include', array($this, 'store_template'));
     add_filter('template_include', array($this, 'store_review_template'));
     add_filter('template_include', array($this, 'product_edit_template'));
     add_filter('query_vars', array($this, 'register_query_var'));
     add_filter('pre_get_posts', array($this, 'store_query_filter'));
     add_filter('woocommerce_locate_template', array($this, 'account_migration_template'));
 }
Пример #4
0
 /**
  * Load Settings Menu for Pro
  *
  * @since 2.4
  *
  * @param  array $sub_settins
  *
  * @return array
  */
 public function load_settings_menu($sub_settins)
 {
     $dokan_shipping_option = get_option('woocommerce_dokan_product_shipping_settings');
     $enable_shipping = isset($dokan_shipping_option['enabled']) ? $dokan_shipping_option['enabled'] : 'yes';
     if ($enable_shipping == 'yes') {
         $sub_settins['shipping'] = array('title' => __('Shipping', 'dokan'), 'icon' => '<i class="fa fa-truck"></i>', 'url' => dokan_get_navigation_url('settings/shipping'), 'pos' => 70);
     }
     $sub_settins['social'] = array('title' => __('Social Profile', 'dokan'), 'icon' => '<i class="fa fa-share-alt-square"></i>', 'url' => dokan_get_navigation_url('settings/social'), 'pos' => 90);
     if (dokan_get_option('store_seo', 'dokan_general', 'on') === 'on') {
         $sub_settins['seo'] = array('title' => __('Store SEO', 'dokan'), 'icon' => '<i class="fa fa-globe"></i>', 'url' => dokan_get_navigation_url('settings/seo'), 'pos' => 110);
     }
     return $sub_settins;
 }
Пример #5
0
function tokopress_dokan_layout_class($layout)
{
    if (dokan_is_store_page()) {
        if (dokan_get_option('enable_theme_store_sidebar', 'dokan_general', 'off') == 'off') {
            $layout = 'layout-2c-l';
        } else {
            if (!of_get_option('tokopress_wc_hide_products_sidebar')) {
                $layout = 'layout-2c-l';
            } else {
                $layout = 'layout-1c-full';
            }
        }
    }
    return $layout;
}
Пример #6
0
 /**
  * Load autometically when class inistantiate
  *
  * @since 2.4
  *
  * @uses actions|filter hooks
  */
 public function __construct()
 {
     $this->quick_edit = dokan_get_option('review_edit', 'dokan_selling', 'off') == 'on' ? true : false;
     add_filter('dokan_get_dashboard_nav', array($this, 'add_review_menu'));
     add_action('dokan_load_custom_template', array($this, 'load_review_template'));
     add_action('dokan_review_content_inside_before', array($this, 'show_seller_enable_message'));
     add_action('dokan_review_content_area_header', array($this, 'dokan_review_header_render'), 10);
     add_action('dokan_review_content', array($this, 'dokan_review_content_render'), 10);
     add_action('dokan_review_content_status_filter', array($this, 'dokan_review_status_filter'), 10, 2);
     add_action('dokan_review_content_listing', array($this, 'dokan_review_content_listing'), 10, 2);
     add_action('dokan_review_listing_table_body', array($this, 'dokan_render_listing_table_body'), 10);
     add_action('dokan_review_content_inside_after', array($this, 'dokan_render_listing_table_script_template'), 10);
     add_action('template_redirect', array($this, 'handle_status'), 10);
     add_action('wp_ajax_dokan_comment_status', array($this, 'ajax_comment_status'));
     add_action('wp_ajax_dokan_update_comment', array($this, 'ajax_update_comment'));
 }
Пример #7
0
/**
 * Get active withdraw methods.
 *
 * Default is paypal
 *
 * @return array
 */
function dokan_withdraw_get_active_methods()
{
    $methods = dokan_get_option('withdraw_methods', 'dokan_selling', array('paypal'));
    return $methods;
}
Пример #8
0
 public function __construct()
 {
     $this->quick_edit = dokan_get_option('review_edit', 'dokan_selling', 'off') == 'on' ? true : false;
 }
Пример #9
0
 /**
  * Mark a order as processing
  *
  * Fires from frontend seller dashboard
  */
 function process_order()
 {
     if (!is_admin()) {
         die;
     }
     if (!current_user_can('dokandar') && dokan_get_option('order_status_change', 'dokan_selling', 'on') != 'on') {
         wp_die(__('You do not have sufficient permissions to access this page.', 'dokan'));
     }
     if (!check_admin_referer('dokan-mark-order-processing')) {
         wp_die(__('You have taken too long. Please go back and retry.', 'dokan'));
     }
     $order_id = isset($_GET['order_id']) && (int) $_GET['order_id'] ? (int) $_GET['order_id'] : '';
     if (!$order_id) {
         die;
     }
     if (!dokan_is_seller_has_order(get_current_user_id(), $order_id)) {
         wp_die(__('You do not have permission to change this order', 'dokan'));
     }
     $order = new WC_Order($order_id);
     $order->update_status('processing');
     wp_safe_redirect(wp_get_referer());
 }
Пример #10
0
/**
 * Redirect My order in Login page without user logged login
 *
 * @since 2.4
 *
 * @return [redirect]
 */
function dokan_myorder_login_check()
{
    global $post;
    if (!$post) {
        return;
    }
    if (!isset($post->ID)) {
        return;
    }
    $my_order_page_id = dokan_get_option('my_orders', 'dokan_pages');
    if ($my_order_page_id == $post->ID) {
        dokan_redirect_login();
    }
}
Пример #11
0
 /**
  * Add body class for dokan-dashboard
  *
  * @param array $classes
  */
 function add_dashboard_template_class($classes)
 {
     $page_id = dokan_get_option('dashboard', 'dokan_pages');
     if (!$page_id) {
         return $classes;
     }
     if (is_page($page_id) || get_query_var('edit') && is_singular('product')) {
         $classes[] = 'dokan-dashboard';
     }
     if (dokan_is_store_page()) {
         $classes[] = 'dokan-store';
     }
     $classes[] = 'dokan-theme-' . get_option('template');
     return $classes;
 }
Пример #12
0
if (dokan_get_option('enable_theme_store_sidebar', 'dokan_general', 'off') == 'off') {
    ?>
        <div id="dokan-secondary" class="dokan-clearfix dokan-w3 dokan-store-sidebar" role="complementary" style="margin-right:3%;">
            <div class="dokan-widget-area widget-collapse">
                 <?php 
    do_action('dokan_sidebar_store_before', $store_user, $store_info);
    ?>
                <?php 
    if (!dynamic_sidebar('sidebar-store')) {
        $args = array('before_widget' => '<aside class="widget">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>');
        if (class_exists('Dokan_Store_Location')) {
            the_widget('Dokan_Store_Category_Menu', array('title' => __('Store Category', 'dokan')), $args);
            if (dokan_get_option('store_map', 'dokan_general', 'on') == 'on') {
                the_widget('Dokan_Store_Location', array('title' => __('Store Location', 'dokan')), $args);
            }
            if (dokan_get_option('contact_seller', 'dokan_general', 'on') == 'on') {
                the_widget('Dokan_Store_Contact_Form', array('title' => __('Contact Seller', 'dokan')), $args);
            }
        }
    }
    ?>

                <?php 
    do_action('dokan_sidebar_store_after', $store_user, $store_info);
    ?>
            </div>
        </div><!-- #secondary .widget-area -->
    <?php 
} else {
    get_sidebar('store');
}
Пример #13
0
                            <?php 
        wc_get_template_part('content', 'product');
        ?>

                        <?php 
    }
    ?>
                    </ul>
                </div>
            </div> <!-- .slider-container -->
        <?php 
}
?>

        <?php 
if (dokan_get_option('show_top_rated', 'dokan_home', 'on') == 'on') {
    ?>
            <div class="slider-container woocommerce">
                <h2 class="slider-heading"><?php 
    _e('Top Rated Products', 'dokan');
    ?>
</h2>

                <div class="product-sliders">
                    <ul class="slides">
                        <?php 
    $top_rated_query = dokan_get_top_rated_products();
    ?>
                        <?php 
    while ($top_rated_query->have_posts()) {
        $top_rated_query->the_post();
Пример #14
0
    /**
     * Generate withdraw request form
     *
     * @param  string  $validate
     *
     * @return void
     */
    function withdraw_form($validate = '')
    {
        global $current_user;
        // show alert messages
        $this->show_alert_messages();
        $balance = $this->get_user_balance($current_user->ID);
        if ($balance < 0) {
            printf('<div class="dokan-alert dokan-alert-danger">%s</div>', sprintf(__('You already withdrawed %s. This amount will deducted from your next balance.', 'dokan'), wc_price($balance)));
        }
        if ($this->has_pending_request($current_user->ID)) {
            ?>
            <div class="dokan-alert dokan-alert-warning">
                <p><strong><?php 
            _e('You\'ve already pending withdraw request(s).', 'dokan');
            ?>
</strong></p>
                <p><?php 
            _e('Until it\'s been cancelled or approved, you can\'t submit any new request.', 'dokan');
            ?>
</p>
            </div>

            <?php 
            $this->withdraw_requests($current_user->ID);
            return;
        } else {
            if (!$this->has_withdraw_balance($current_user->ID)) {
                printf('<div class="dokan-alert dokan-alert-danger">%s</div>', __('You don\'t have sufficient balance for a withdraw request!', 'dokan'));
                return;
            }
        }
        $payment_methods = dokan_withdraw_get_active_methods();
        if (is_wp_error($validate)) {
            $amount = $_POST['witdraw_amount'];
            $withdraw_method = $_POST['withdraw_method'];
        } else {
            $amount = '';
            $withdraw_method = '';
        }
        ?>
        <div class="dokan-alert dokan-alert-danger" style="display: none;">
            <button type="button" class="dokan-close" data-dismiss="alert">&times;</button>
            <strong class="jquery_error_place"></strong>
        </div>

        <span class="ajax_table_shown"></span>
        <form class="dokan-form-horizontal withdraw" role="form" method="post">

            <div class="dokan-form-group">
                <label for="withdraw-amount" class="dokan-w3 dokan-control-label">
                    <?php 
        _e('Withdraw Amount', 'dokan');
        ?>
                </label>

                <div class="dokan-w5 dokan-text-left">
                    <div class="dokan-input-group">
                        <span class="dokan-input-group-addon"><?php 
        echo get_woocommerce_currency_symbol();
        ?>
</span>
                        <input name="witdraw_amount" required number min="<?php 
        echo esc_attr(dokan_get_option('withdraw_limit', 'dokan_selling', 50));
        ?>
" class="dokan-form-control" id="withdraw-amount" name="price" type="number" placeholder="0.00" value="<?php 
        echo $amount;
        ?>
"  >
                    </div>
                </div>
            </div>

            <div class="dokan-form-group">
                <label for="withdraw-method" class="dokan-w3 dokan-control-label">
                    <?php 
        _e('Payment Method', 'dokan');
        ?>
                </label>

                <div class="dokan-w5 dokan-text-left">
                    <select class="dokan-form-control" required name="withdraw_method" id="withdraw-method">
                        <?php 
        foreach ($payment_methods as $method_name) {
            ?>
                            <option <?php 
            selected($withdraw_method, $method_name);
            ?>
value="<?php 
            echo esc_attr($method_name);
            ?>
"><?php 
            echo dokan_withdraw_get_method_title($method_name);
            ?>
</option>
                        <?php 
        }
        ?>
                    </select>
                </div>
            </div>

            <div class="dokan-form-group">
                <div class="dokan-w3 ajax_prev" style="margin-left:23%; width: 200px;">
                    <?php 
        wp_nonce_field('dokan_withdraw', 'dokan_withdraw_nonce');
        ?>
                    <input type="submit" class="dokan-btn dokan-btn-theme" value="<?php 
        esc_attr_e('Submit Request', 'dokan');
        ?>
" name="withdraw_submit">
                </div>
            </div>
        </form>
        <?php 
    }
Пример #15
0
        <p class="form-row form-group form-row-wide">
            <label for="shop-phone"><?php 
_e('Phone Number', 'dokan');
?>
<span class="required">*</span></label>
            <input type="text" class="input-text form-control" name="phone" id="shop-phone" value="<?php 
if (!empty($_POST['phone'])) {
    echo esc_attr($_POST['phone']);
}
?>
" required="required" />
        </p>
        <?php 
$show_toc = dokan_get_option('enable_tc_on_reg', 'dokan_general');
if ($show_toc == 'on') {
    $toc_page_id = dokan_get_option('reg_tc_page', 'dokan_pages');
    if ($toc_page_id != -1) {
        $toc_page_url = get_permalink($toc_page_id);
        ?>
                <p class="form-row form-group form-row-wide">
                    <input class="tc_check_box" type="checkbox" id="tc_agree" name="tc_agree" required="required">
                    <label style="display: inline" for="tc_agree"><?php 
        sprintf(__('I have read and agree to the <a target="_blank" href="%s">Terms &amp; Conditions</a>.', 'dokan'), $toc_page_url);
        ?>
</label>
                </p>
            <?php 
    }
    ?>
        <?php 
}
Пример #16
0
?>
" size="30" />
                        <a href="#" class="dokan-map-find-btn" id="dokan-location-find-btn" type="button"><?php 
_e('Find Address', 'dokan');
?>
</a>
                    </div>

                    <div class="dokan-google-map" id="dokan-map"></div>
                </div>
            </div> <!-- col.md-4 -->
        </div> <!-- .dokan-form-group -->

        <!--terms and conditions enable or not -->
        <?php 
$tnc_enable = dokan_get_option('seller_enable_terms_and_conditions', 'dokan_general', 'off');
if ($tnc_enable == 'on') {
    ?>
            <div class="dokan-form-group">
                <label class="dokan-w3 dokan-control-label"><?php 
    _e('Terms and Conditions', 'dokan');
    ?>
</label>
                <div class="dokan-w5 dokan-text-left dokan_tock_check">
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="dokan_store_tnc_enable" value="on" <?php 
    echo $enable_tnc == 'on' ? 'checked' : '';
    ?>
 name="dokan_store_tnc_enable" ><?php 
    _e('Show terms and conditions in store page', 'dokan');
    </p>

    <p class="form-row form-group form-row-wide">
        <label for="seller-url" class="pull-left"><?php 
_e('Shop URL', 'dokan');
?>
 <span class="required">*</span></label>
        <strong id="url-alart-mgs" class="pull-right"></strong>
        <input type="text" class="input-text form-control" name="shopurl" id="seller-url" value="<?php 
if (!empty($postdata['shopurl'])) {
    echo esc_attr($postdata['shopurl']);
}
?>
" required="required" />
        <small><?php 
echo home_url() . '/' . dokan_get_option('custom_store_url', 'dokan_general', 'store');
?>
/<strong id="url-alart"></strong></small>
    </p>

    <p class="form-row form-group form-row-wide">
        <label for="shop-phone"><?php 
_e('Phone Number', 'dokan');
?>
<span class="required">*</span></label>
        <input type="text" class="input-text form-control" name="phone" id="shop-phone" value="<?php 
if (!empty($postdata['phone'])) {
    echo esc_attr($postdata['phone']);
}
?>
" required="required" />
Пример #18
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);
}
Пример #19
0
    if (dokan_get_option('product_category_style', 'dokan_selling', 'single') == 'single') {
        ?>
                                                    <div class="dokan-form-group">

                                                        <?php 
        $product_cat = -1;
        $term = array();
        $term = wp_get_post_terms($post_id, 'product_cat', array('fields' => 'ids'));
        if ($term) {
            $product_cat = reset($term);
        }
        wp_dropdown_categories(array('show_option_none' => __('- Select a category -', 'dokan'), 'hierarchical' => 1, 'hide_empty' => 0, 'name' => 'product_cat', 'id' => 'product_cat', 'taxonomy' => 'product_cat', 'title_li' => '', 'class' => 'product_cat dokan-form-control chosen', 'exclude' => '', 'selected' => $product_cat));
        ?>
                                                    </div>
                                                <?php 
    } elseif (dokan_get_option('product_category_style', 'dokan_selling', 'single') == 'multiple') {
        ?>
                                                    <div class="dokan-form-group dokan-list-category-box">
                                                        <h5><?php 
        _e('Choose a category', 'dokan');
        ?>
</h5>
                                                        <ul class="dokan-checkbox-cat">
                                                            <?php 
        $term = array();
        $term = wp_get_post_terms($post_id, 'product_cat', array('fields' => 'ids'));
        include_once DOKAN_LIB_DIR . '/class.category-walker.php';
        wp_list_categories(array('walker' => new DokanCategoryWalker(), 'title_li' => '', 'id' => 'product_cat', 'hide_empty' => 0, 'taxonomy' => 'product_cat', 'hierarchical' => 1, 'selected' => $term));
        ?>
                                                        </ul>
                                                    </div>
Пример #20
0
/**
 * Get navigation url for the dokan dashboard
 *
 * @param  string $name endpoint name
 * @return string url
 */
function dokan_get_navigation_url($name = '')
{
    $page_id = dokan_get_option('dashboard', 'dokan_pages');
    if (!$page_id) {
        return;
    }
    if (!empty($name)) {
        $url = get_permalink($page_id) . $name . '/';
    } else {
        $url = get_permalink($page_id);
    }
    return apply_filters('dokan_get_navigation_url', $url);
}
Пример #21
0
_e('Shop URL', 'dokan');
?>
 <span class="required">*</span></label>
            <strong id="url-alart-mgs" class="pull-right"></strong>
            <input type="text" class="input-text form-control" name="shopurl" id="seller-url" value="<?php 
if (empty($cu_slug)) {
    if (!empty($_POST['shopurl'])) {
        echo esc_attr($_POST['shopurl']);
    }
} else {
    echo esc_attr($cu_slug);
}
?>
" required="required" />
            <small><?php 
echo home_url() . '/' . dokan_get_option('custom_store_url', 'dokan_selling', 'store');
?>
/<strong id="url-alart"></strong></small>
        </p>

        <p class="form-row form-group form-row-wide">
            <label for="seller-address"><?php 
_e('Address', 'dokan');
?>
<span class="required">*</span></label>
            <textarea type="text" id="seller-address" name="address" class="form-control input" required="required"><?php 
if (!empty($_POST['address'])) {
    echo esc_textarea($_POST['address']);
}
?>
</textarea>
Пример #22
0
/**
 * Get active withdraw order status.
 *
 * Default is 'completed', 'processing', 'on-hold'
 *
 */
function dokan_withdraw_get_active_order_status()
{
    $order_status = dokan_get_option('withdraw_order_status', 'dokan_selling', array('wc-completed'));
    return apply_filters('dokan_withdraw_active_status', $order_status);
}
Пример #23
0
/**
 * Get page permalink based on context
 *
 * @param string $page
 * @param string $context
 * @return string url of the page
 */
function dokan_get_page_url($page, $context = 'dokan')
{
    if ($context == 'woocommerce') {
        $page_id = wc_get_page_id($page);
    } else {
        $page_id = dokan_get_option($page, 'dokan_pages');
    }
    return get_permalink($page_id);
}
Пример #24
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;
         }
     }
 }
Пример #25
0
                        <ul class="list-unstyled order-status">
                            <li>
                                <span><?php 
_e('Order Status:', 'dokan');
?>
</span>
                                <label class="dokan-label dokan-label-<?php 
echo dokan_get_order_status_class($order->post_status);
?>
"><?php 
echo isset($statuses[$order->post_status]) ? $statuses[$order->post_status] : $order->post_status;
?>
</label>

                                <?php 
if (dokan_get_option('order_status_change', 'dokan_selling', 'on') == 'on') {
    ?>
                                    <a href="#" class="dokan-edit-status"><small><?php 
    _e('&nbsp; Edit', 'dokan');
    ?>
</small></a>
                                <?php 
}
?>
                            </li>
                            <li class="dokan-hide">
                                <form id="dokan-order-status-form" action="" method="post">

                                    <select id="order_status" name="order_status" class="form-control">
                                        <?php 
foreach ($statuses as $status => $label) {
Пример #26
0
/**
 * Get active withdraw order status.
 * 
 * Default is 'completed', 'processing', 'on-hold' 
 * 
 */
function dokan_withdraw_get_active_order_status()
{
    $order_status = dokan_get_option('withdraw_order_status', 'dokan_selling', array('completed', 'processing', 'on-hold'));
    return $order_status;
}
Пример #27
0
function dokan_seller_reg_form_fields()
{
    $role = isset($_POST['role']) ? $_POST['role'] : 'customer';
    $role_style = $role == 'customer' ? ' style="display:none"' : '';
    ?>
    <div class="show_if_seller"<?php 
    echo $role_style;
    ?>
>

        <div class="split-row form-row-wide">
            <p class="form-row form-group">
                <label for="first-name"><?php 
    _e('First Name', 'dokan');
    ?>
 <span class="required">*</span></label>
                <input type="text" class="input-text form-control" name="fname" id="first-name" value="<?php 
    if (!empty($_POST['fname'])) {
        echo esc_attr($_POST['fname']);
    }
    ?>
" required="required" />
            </p>

            <p class="form-row form-group">
                <label for="last-name"><?php 
    _e('Last Name', 'dokan');
    ?>
 <span class="required">*</span></label>
                <input type="text" class="input-text form-control" name="lname" id="last-name" value="<?php 
    if (!empty($_POST['lname'])) {
        echo esc_attr($_POST['lname']);
    }
    ?>
" required="required" />
            </p>
        </div>

        <p class="form-row form-group form-row-wide">
            <label for="company-name"><?php 
    _e('Shop Name', 'dokan');
    ?>
 <span class="required">*</span></label>
            <input type="text" class="input-text form-control" name="shopname" id="company-name" value="<?php 
    if (!empty($_POST['shopname'])) {
        echo esc_attr($_POST['shopname']);
    }
    ?>
" required="required" />
        </p>

        <p class="form-row form-group form-row-wide">
            <label for="seller-url" class="pull-left"><?php 
    _e('Shop URL', 'dokan');
    ?>
 <span class="required">*</span></label>
            <strong id="url-alart-mgs" class="pull-right"></strong>
            <input type="text" class="input-text form-control" name="shopurl" id="seller-url" value="<?php 
    if (!empty($_POST['shopurl'])) {
        echo esc_attr($_POST['shopurl']);
    }
    ?>
" required="required" />
            <small><?php 
    echo home_url() . '/' . dokan_get_option('custom_store_url', 'dokan_selling', 'store');
    ?>
/<strong id="url-alart"></strong></small>
        </p>

        <p class="form-row form-group form-row-wide">
            <label for="seller-address"><?php 
    _e('Address', 'dokan');
    ?>
<span class="required">*</span></label>
            <textarea type="text" id="seller-address" name="address" class="form-control input" required="required"><?php 
    if (!empty($_POST['address'])) {
        echo esc_textarea($_POST['address']);
    }
    ?>
</textarea>
        </p>

        <p class="form-row form-group form-row-wide">
            <label for="shop-phone"><?php 
    _e('Phone', 'dokan');
    ?>
<span class="required">*</span></label>
            <input type="text" class="input-text form-control" name="phone" id="shop-phone" value="<?php 
    if (!empty($_POST['phone'])) {
        echo esc_attr($_POST['phone']);
    }
    ?>
" required="required" />
        </p>

        <?php 
    do_action('dokan_seller_registration_field_after');
    ?>

    </div>

    <?php 
    do_action('dokan_reg_form_field');
    ?>

    <p class="form-row form-group user-role">
        <label class="radio">
            <input type="radio" name="role" value="customer"<?php 
    checked($role, 'customer');
    ?>
>
            <?php 
    _e('I am a customer', 'dokan');
    ?>
        </label>

        <label class="radio">
            <input type="radio" name="role" value="seller"<?php 
    checked($role, 'seller');
    ?>
>
            <?php 
    _e('I am a seller', 'dokan');
    ?>
        </label>
        <?php 
    do_action('dokan_registration_form_role', $role);
    ?>
    </p>

    <?php 
}
Пример #28
0
    ?>
</p>

            <?php 
}
?>
        </div>

    </div><!-- .dokan-single-store -->

    <?php 
do_action('woocommerce_after_main_content');
?>

    <?php 
if (dokan_get_option('enable_theme_store_sidebar', 'dokan_general', 'off') == 'off') {
    ?>
        <?php 
    get_sidebar('dokan');
    ?>
    <?php 
} else {
    ?>
        <?php 
    if (!of_get_option('tokopress_wc_hide_products_sidebar')) {
        ?>
            <?php 
        get_sidebar('shop');
        ?>
        <?php 
    }
Пример #29
0
                    <?php 
dynamic_sidebar('footer-4');
?>
                </div>
            </div> <!-- .footer-widget-area -->
        </div>
    </div>

    <div class="copy-container">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="footer-copy">
                        <div class="col-md-6 site-info">
                            <?php 
$footer_text = dokan_get_option('footer_text', 'dokan_general');
if (empty($footer_text)) {
    printf(__('&copy; %d, %s. All rights are reserved.', 'dokan'), date('Y'), get_bloginfo('name'));
    printf(__('Powered <a href="%s" target="_blank">Dokan</a> - by <a href="%s" target="_blank">weDevs</a>', 'dokan'), esc_url('http://wedevs.com/themes/dokan/?utm_source=dokan&utm_medium=theme_footer&utm_campaign=product'), esc_url('http://wedevs.com/?utm_source=dokan&utm_medium=theme_footer&utm_campaign=product'));
} else {
    echo $footer_text;
}
?>
                        </div><!-- .site-info -->

                        <div class="col-md-6 footer-gateway">
                            <?php 
wp_nav_menu(array('theme_location' => 'footer', 'depth' => 1, 'container_class' => 'footer-menu-container clearfix', 'menu_class' => 'menu list-inline pull-right'));
?>
                        </div>
                    </div>
" data-update="<?php 
    _e('Insert file URL', 'dokan');
    ?>
"><?php 
    echo str_replace(' ', '&nbsp;', __('Choose file', 'woocommerce'));
    ?>
</a>
                <a href="#" class="dokan-btn dokan-btn-sm dokan-btn-danger delete"><span><?php 
    _e('Delete', 'dokan');
    ?>
</span></a>
            </p>
        </td>
    </tr>
    <?php 
} elseif (dokan_get_option('product_style', 'dokan_selling', 'old') == 'new') {
    ?>
    <tr>
        <td>
            <input type="text" class="input_text" placeholder="<?php 
    _e('File Name', 'dokan');
    ?>
" name="_wc_file_names[]" value="<?php 
    echo esc_attr($file['name']);
    ?>
" />

        </td>
        <td>
            <p>
                <input type="text" class="input_text wc_file_url" placeholder="<?php