Esempio n. 1
0
    /**
     * Callback for Register_prouduct_tab function
     *
     * @since 2.0
     *
     * @return void
     */
    function shipping_tab()
    {
        global $post;
        $_overwrite_shipping = get_post_meta($post->ID, '_overwrite_shipping', true);
        $dps_processing = get_user_meta($post->post_author, '_dps_pt', true);
        $from = get_user_meta($post->post_author, '_dps_form_location', true);
        $dps_country_rates = get_user_meta($post->post_author, '_dps_country_rates', true);
        $shipping_policy = get_user_meta($post->post_author, '_dps_ship_policy', true);
        $refund_policy = get_user_meta($post->post_author, '_dps_refund_policy', true);
        $product_processing_time = get_post_meta($post->ID, '_dps_processing_time', true);
        $processing_time = $dps_processing;
        if ($_overwrite_shipping == 'yes') {
            $processing_time = $product_processing_time ? $product_processing_time : $dps_processing;
        }
        $country_obj = new WC_Countries();
        $countries = $country_obj->countries;
        ?>

        <?php 
        if ($processing_time) {
            ?>
            <p>
                <strong>
                    <?php 
            _e('Ready to ship in', 'dokan');
            ?>
 <?php 
            echo dokan_get_processing_time_value($processing_time);
            ?>

                    <?php 
            if ($from) {
                echo __('from', 'dokan') . ' ' . $countries[$from];
            }
            ?>
                </strong>
            </p>
            <hr>
        <?php 
        }
        ?>

        <?php 
        if ($dps_country_rates) {
            ?>

            <h4><?php 
            _e('Shipping Calculation:', 'dokan');
            ?>
</h4>

            <div class="dokan-shipping-calculate-wrapper dokan-form-inline">

                <div class="dokan-shipping-country-wrapper dokan-form-group dokan-w3">

                    <label for="dokan-shipping-country" class="dokan-control-label"><?php 
            _e('Country', 'dokan');
            ?>
</label>
                    <select name="dokan-shipping-country" id="dokan-shipping-country" class="dokan-shipping-country dokan-form-control" data-product_id="<?php 
            echo $post->ID;
            ?>
" data-author_id="<?php 
            echo $post->post_author;
            ?>
">
                        <option value=""><?php 
            _e('--Select Country--', 'dokan');
            ?>
</option>
                        <?php 
            foreach ($dps_country_rates as $country => $cost) {
                ?>
                            <option value="<?php 
                echo $country;
                ?>
"><?php 
                echo $country == 'everywhere' ? _e('Other Countries') : $countries[$country];
                ?>
</option>
                        <?php 
            }
            ?>
                    </select>

                </div>

                <div class="dokan-shipping-state-wrapper dokan-form-group">

                </div>

                <div class="dokan-shipping-qty-wrapper dokan-form-group dokan-w3">
                    <label for="dokan-shipping-qty" class="dokan-control-label"><?php 
            _e('Quantity', 'dokan');
            ?>
</label>
                    <input type="number" class="dokan-shipping-qty dokan-form-control" id="dokan-shipping-qty" name="dokan-shipping-qty" value="1" placeholder="1">
                </div>

                <button class="dokan-btn dokan-btn-theme dokan-shipping-calculator dokan-w3"><?php 
            _e('Get Shipping Cost', 'dokan');
            ?>
</button>

                <div class="dokan-clearfix"></div>

                <div class="dokan-shipping-price-wrapper dokan-form-group">

                </div>

                <div class="dokan-clearfix"></div>
            </div>

        <?php 
        }
        ?>

        <?php 
        if ($shipping_policy) {
            ?>
            <p>&nbsp;</p>
            <strong><?php 
            _e('Shipping Policy', 'dokan');
            ?>
</strong>
            <?php 
            echo wpautop($shipping_policy);
            ?>
        <?php 
        }
        ?>

        <?php 
        if ($refund_policy) {
            ?>
            <hr>
            <p>&nbsp;</p>
            <strong><?php 
            _e('Refund Policy', 'dokan');
            ?>
</strong>
            <hr>
            <?php 
            echo wpautop($refund_policy);
            ?>
        <?php 
        }
        ?>
        <?php 
    }
Esempio n. 2
0
    /**
     * Callback for Register_prouduct_tab function
     * @return [type] [description]
     */
    function shipping_tab()
    {
        global $post;
        $dps_processing = get_user_meta($post->post_author, '_dps_pt', true);
        $from = get_user_meta($post->post_author, '_dps_form_location', true);
        $dps_country_rates = get_user_meta($post->post_author, '_dps_country_rates', true);
        $dps_state_rates = get_user_meta($post->post_author, '_dps_state_rates', true);
        $shipping_policy = get_user_meta($post->post_author, '_dps_ship_policy', true);
        $refund_policy = get_user_meta($post->post_author, '_dps_refund_policy', true);
        // Store wide shipping info
        $store_shipping_type_price = (double) get_user_meta($post->post_author, '_dps_shipping_type_price', true);
        $additional_product_cost = get_post_meta($post->ID, '_additional_price', true);
        $base_shipping_type_price = (double) $store_shipping_type_price + ($additional_product_cost ? (double) $additional_product_cost : 0);
        $additional_qty_product_price = get_post_meta($post->ID, '_additional_qty', true);
        $dps_additional_qty = get_user_meta($post->post_author, '_dps_additional_qty', true);
        $additional_qty_price = $additional_qty_product_price ? $additional_qty_product_price : $dps_additional_qty;
        $product_processing_time = get_post_meta($post->ID, '_dps_processing_time', true);
        $processing_time = $product_processing_time ? $product_processing_time : $dps_processing;
        $country_obj = new WC_Countries();
        $countries = $country_obj->countries;
        $states = $country_obj->states;
        ?>

        <?php 
        if ($base_shipping_type_price) {
            ?>
             <p>
                    <strong>
                        <?php 
            _e('Base Shipping Cost for this product : ', 'dokan');
            ?>
 <?php 
            echo wc_price($base_shipping_type_price);
            ?>
                    </strong>
            </p>
        <?php 
        }
        ?>

        <?php 
        if ($base_shipping_type_price) {
            ?>
             <p>
                    <strong>
                        <?php 
            _e('Shipping Cost of additional quantity for this product : ', 'dokan');
            ?>
 <?php 
            echo wc_price($additional_qty_price);
            ?>
                    </strong>
            </p>

        <?php 
        }
        ?>

        <?php 
        if ($additional_qty_price) {
            ?>
                <p>
                    <strong>
                    <?php 
            _e('Ready to ship in', 'dokan');
            ?>
 <?php 
            echo dokan_get_processing_time_value($processing_time);
            ?>

                    <?php 
            if ($from) {
                echo __('from', 'dokan') . ' ' . $countries[$from];
            }
            ?>
                </strong>
            </p>
            <hr>
        <?php 
        }
        ?>

        <?php 
        if ($dps_country_rates) {
            ?>
            <table class="table">
                <thead>
                    <tr>
                        <th><?php 
            _e('Ship To', 'dokan');
            ?>
</th>
                        <th><?php 
            _e('Cost', 'dokan');
            ?>
</th>
                    </tr>
                </thead>
                <tbody>

                <?php 
            foreach ($dps_country_rates as $country => $cost) {
                ?>
                    <tr>
                        <td>
                            <?php 
                if ($country == 'everywhere') {
                    _e('Everywhere Else', 'dokan');
                } else {
                    echo $countries[$country];
                }
                ?>
                        </td>
                        <td>
                            <?php 
                if (isset($dps_state_rates[$country]) && count($dps_state_rates[$country])) {
                    echo '--------';
                } else {
                    echo wc_price($cost);
                }
                ?>
                        </td>
                    </tr>
                    <?php 
                if (isset($dps_state_rates[$country]) && count($dps_state_rates[$country])) {
                    ?>
                        <tr>
                            <td>
                                <table width="100%" class="table">
                                    <thead>
                                        <tr>
                                            <th><?php 
                    _e('Shipping state', 'dokan');
                    ?>
</th>
                                            <th><?php 
                    _e('Cost', 'dokan');
                    ?>
</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php 
                    foreach ($dps_state_rates[$country] as $state_code => $state_cost) {
                        ?>
                                            <tr>
                                                <td>
                                                    <?php 
                        if ($state_code == 'everywhere') {
                            _e('Everywhere Else', 'dokan');
                        } else {
                            if (isset($states[$country][$state_code])) {
                                echo $states[$country][$state_code];
                            } else {
                                echo $state_code;
                            }
                        }
                        ?>
                                                </td>
                                                <td><?php 
                        echo wc_price($state_cost);
                        ?>
</td>

                                            </tr>
                                        <?php 
                    }
                    ?>
                                    </tbody>
                                </table>  
                            </td>   
                        </tr>
                    <?php 
                }
                ?>
                <?php 
            }
            ?>
                    </tbody>
                </table>

            <?php 
        }
        ?>

            <p>&nbsp;</p>

        <?php 
        if ($shipping_policy) {
            ?>
            <strong><?php 
            _e('Shipping Policy', 'dokan');
            ?>
</strong>
            <hr>
            <?php 
            echo wpautop($shipping_policy);
            ?>
        <?php 
        }
        ?>

        <p>&nbsp;</p>

        <?php 
        if ($refund_policy) {
            ?>
            <strong><?php 
            _e('Refund Policy', 'dokan');
            ?>
</strong>
            <hr>
            <?php 
            echo wpautop($refund_policy);
            ?>
        <?php 
        }
        ?>
        <?php 
    }