Exemplo n.º 1
2
/**
 * Displays the store lists
 *
 * @since 2.4
 *
 * @param  array $atts
 *
 * @return string
 */
function store_listing($atts)
{
    global $post;
    /**
     * Filter return the number of store listing number per page.
     *
     * @since 2.2
     *
     * @param array
     */
    $attr = shortcode_atts(apply_filters('dokan_store_listing_per_page', array('per_page' => 10)), $atts);
    $paged = max(1, get_query_var('paged'));
    $limit = $attr['per_page'];
    $offset = ($paged - 1) * $limit;
    $sellers = dokan_get_sellers($limit, $offset);
    ob_start();
    if ($sellers['users']) {
        ?>
    <ul class="dokan-seller-wrap">
        <?php 
        foreach ($sellers['users'] as $seller) {
            $store_info = dokan_get_store_info($seller->ID);
            $banner_id = isset($store_info['banner']) ? $store_info['banner'] : 0;
            $store_name = isset($store_info['store_name']) ? esc_html($store_info['store_name']) : __('N/A', 'dokan');
            $store_url = dokan_get_store_url($seller->ID);
            ?>

            <li class="dokan-single-seller">
                <div class="dokan-store-thumbnail">

                    <a href="<?php 
            echo $store_url;
            ?>
">
                        <?php 
            if ($banner_id) {
                $banner_url = wp_get_attachment_image_src($banner_id, 'medium');
                ?>
                            <img class="dokan-store-img" src="<?php 
                echo esc_url($banner_url[0]);
                ?>
" alt="<?php 
                echo esc_attr($store_name);
                ?>
">
                        <?php 
            } else {
                ?>
                            <img class="dokan-store-img" src="<?php 
                echo dokan_get_no_seller_image();
                ?>
" alt="<?php 
                _e('No Image', 'dokan');
                ?>
">
                        <?php 
            }
            ?>
                    </a>

                    <div class="dokan-store-caption">
                        <h3><a href="<?php 
            echo $store_url;
            ?>
"><?php 
            echo $store_name;
            ?>
</a></h3>

                        <address>

                            <?php 
            if (isset($store_info['address']) && !empty($store_info['address'])) {
                echo dokan_get_seller_address($seller->ID);
            }
            ?>

                            <?php 
            if (isset($store_info['phone']) && !empty($store_info['phone'])) {
                ?>
                                <br>
                                <abbr title="<?php 
                _e('Phone Number', 'dokan');
                ?>
"><?php 
                _e('P:', 'dokan');
                ?>
</abbr> <?php 
                echo esc_html($store_info['phone']);
                ?>
                            <?php 
            }
            ?>

                        </address>

                        <p><a class="dokan-btn dokan-btn-theme" href="<?php 
            echo $store_url;
            ?>
"><?php 
            _e('Visit Store', 'dokan');
            ?>
</a></p>

                    </div> <!-- .caption -->
                </div> <!-- .thumbnail -->
            </li> <!-- .single-seller -->
        <?php 
        }
        ?>
    </ul> <!-- .dokan-seller-wrap -->

    <?php 
        $user_count = $sellers['count'];
        $num_of_pages = ceil($user_count / $limit);
        if ($num_of_pages > 1) {
            echo '<div class="pagination-container clearfix">';
            $page_links = paginate_links(array('current' => $paged, 'total' => $num_of_pages, 'base' => str_replace($post->ID, '%#%', esc_url(get_pagenum_link($post->ID))), 'type' => 'array', 'prev_text' => __('&larr; Previous', 'dokan'), 'next_text' => __('Next &rarr;', 'dokan')));
            if ($page_links) {
                $pagination_links = '<div class="pagination-wrap">';
                $pagination_links .= '<ul class="pagination"><li>';
                $pagination_links .= join("</li>\n\t<li>", $page_links);
                $pagination_links .= "</li>\n</ul>\n";
                $pagination_links .= '</div>';
                echo $pagination_links;
            }
            echo '</div>';
        }
        ?>

    <?php 
    } else {
        ?>
        <p class="dokan-error"><?php 
        _e('No seller found!', 'dokan');
        ?>
</p>
    <?php 
    }
    $content = ob_get_clean();
    return apply_filters('dokan_seller_listing', $content, $attr);
}
Exemplo n.º 2
0
                <?php 
if (isset($store_info['store_name'])) {
    ?>
                    <li class="store-name"><?php 
    echo esc_html($store_info['store_name']);
    ?>
</li>
                <?php 
}
?>
                <?php 
if (isset($store_info['address']) && !empty($store_info['address'])) {
    ?>
                    <li class="dokan-store-address"><i class="fa fa-map-marker"></i>
                        <?php 
    echo dokan_get_seller_address($store_user->ID);
    ?>
                    </li>
                <?php 
}
?>

                <?php 
if (isset($store_info['phone']) && !empty($store_info['phone'])) {
    ?>
                    <li class="dokan-store-phone">
                        <i class="fa fa-mobile"></i>
                        <a href="tel:<?php 
    echo esc_html($store_info['phone']);
    ?>
"><?php 
Exemplo n.º 3
0
 /**
  * calculate_shipping function.
  *
  * @access public
  *
  * @param mixed $package
  *
  * @return void
  */
 public function calculate_shipping($package)
 {
     $products = $package['contents'];
     $destination_country = isset($package['destination']['country']) ? $package['destination']['country'] : '';
     $destination_state = isset($package['destination']['state']) ? $package['destination']['state'] : '';
     $amount = 0.0;
     if ($products) {
         $amount = $this->calculate_per_seller($products, $destination_country, $destination_state);
     }
     $tax_rate = $this->tax_status == 'none' ? false : '';
     if ($tax_rate === '') {
         $rates = WC_Tax::get_shipping_tax_rates();
         $taxRate = reset($rates);
         $taxkey = key($rates);
         $tax_rates = array();
         $shippingTaxes = 0;
         $price = $this->calculate_per_seller_prices($products, $destination_country, $destination_state);
         //var_dump($price);
         // var_dump($rates);
         if (!empty($price)) {
             foreach ($price as $seller_id => $value) {
                 //TODO: Check if taxxing from same state;
                 //var_dump($_product->post->post_author);
                 $country_obj = new WC_Countries();
                 $countries = $country_obj->countries;
                 $states = $country_obj->states;
                 $selleraddress = dokan_get_seller_address($seller_id, true);
                 $sellerState = $selleraddress['state'];
                 $stateCode = array_search(ucfirst(strtolower($sellerState)), $states['US']);
                 if ($stateCode !== false) {
                     $sellerState = $stateCode;
                 }
                 $location = WC()->customer->get_taxable_address();
                 $buyerState = $location[1];
                 if ($buyerState == $sellerState) {
                     $shippingCost = array_sum($value['addition_price']) + $value['default'] + array_sum($value['qty']) + $value['add_product'] + (isset($value['state_rates']) ? $value['state_rates'] : 0);
                     $shippingTaxes += $shippingCost * $taxRate['rate'] / 100;
                     //var_dump($shippingCost, $taxRate);
                 }
             }
         }
         $tax_rate[$taxkey] = $shippingTaxes;
         //var_dump($tax_rate);
     }
     $rate = array('id' => $this->id, 'label' => $this->title, 'cost' => $amount, 'taxes' => $tax_rate);
     // Register the rate
     $this->add_rate($rate);
 }
Exemplo n.º 4
0
/**
 * Prints seller info in product single page
 *
 * @global WC_Product $product
 * @param type $val
 */
function dokan_product_seller_tab($val)
{
    global $product;
    $author = get_user_by('id', $product->post->post_author);
    $store_info = dokan_get_store_info($author->ID);
    ?>
    <h2><?php 
    _e('Seller Information', 'dokan');
    ?>
</h2>
    <ul class="list-unstyled">

        <?php 
    if (!empty($store_info['store_name'])) {
        ?>
            <li class="store-name">
                <span><?php 
        _e('Store Name:', 'dokan');
        ?>
</span>
                <span class="details">
                    <?php 
        echo esc_html($store_info['store_name']);
        ?>
                </span>
            </li>
        <?php 
    }
    ?>

        <li class="seller-name">
            <span>
                <?php 
    _e('Seller:', 'dokan');
    ?>
            </span>

            <span class="details">
                <?php 
    printf('<a href="%s">%s</a>', dokan_get_store_url($author->ID), $author->display_name);
    ?>
            </span>
        </li>
        <?php 
    if (!empty($store_info['address'])) {
        ?>
            <li class="store-address">
                <span><b><?php 
        _e('Address:', 'dokan');
        ?>
</b></span>
                <span class="details">
                    <?php 
        echo dokan_get_seller_address($author->ID);
        ?>
                </span>
            </li>
        <?php 
    }
    ?>

        <li class="clearfix">
            <?php 
    dokan_get_readable_seller_rating($author->ID);
    ?>
        </li>
    </ul>

    <?php 
}
Exemplo n.º 5
0
        <span class="details">
            <?php 
printf('<a href="%s">%s</a>', dokan_get_store_url($author->ID), $author->display_name);
?>
        </span>
    </li>
    <?php 
if (!empty($store_info['address'])) {
    ?>
        <li class="store-address">
            <span><b><?php 
    _e('Address:', 'dokan');
    ?>
</b></span>
            <span class="details">
                <?php 
    echo dokan_get_seller_address($author->ID);
    ?>
            </span>
        </li>
    <?php 
}
?>

    <li class="clearfix">
        <?php 
dokan_get_readable_seller_rating($author->ID);
?>
    </li>
</ul>