Exemple #1
0
function show_shipping_options($post, $single_names)
{
    $shipping_values = get_shipping_options($post->ID);
    if ($shipping_values != 'none') {
        ?>
        <table class="shipping-table">
            <tr>
                <td>
                    <?php 
        echo $single_names['product_shipping'];
        ?>
                </td>
                <td>
                    <ul>
                        <?php 
        foreach ($shipping_values as $i => $shipping_value) {
            if ($shipping_value != null) {
                echo '<li>' . get_post_meta($post->ID, "_shipping-label" . $i, true) . ' : ' . price_format($shipping_value) . '</li>';
            }
        }
        ?>
                    </ul>
                </td>
            </tr>
        </table>
    <?php 
    }
}
/**
 * Returns shipping options table
 *
 * @param int $product_id
 * @param array $v_single_names
 * @return string
 */
function get_shipping_options_table($product_id, $v_single_names = null)
{
    $single_names = isset($v_single_names) ? $v_single_names : get_single_names();
    $shipping_values = get_shipping_options($product_id);
    $table = '';
    if ($shipping_values != 'none') {
        $table .= '<table class="shipping-table">';
        $table .= '<tr>';
        $table .= '<td>';
        $table .= $single_names['product_shipping'];
        $table .= '</td>';
        $table .= '<td>';
        $table .= '<ul>';
        foreach ($shipping_values as $i => $shipping_value) {
            if ($shipping_value != null) {
                $table .= '<li>' . get_shipping_label($i, $product_id) . ' : ' . price_format($shipping_value) . '</li>';
            }
        }
        $table .= '</ul>';
        $table .= '</td>';
        $table .= '</tr>';
        $table .= '</table>';
    }
    return $table;
}
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
/**
 * The template to display product shipping on product page or with a shortcode
 *
 * Copy it to your theme implecode folder to edit the output: your-theme-folder-name/implecode/product-shipping.php
 *
 * @version		1.1.2
 * @package		ecommerce-product-catalog/templates/template-parts/product-page
 * @author 		Norbert Dreszer
 */
$single_names = get_single_names();
$product_id = ic_get_product_id();
$shipping_values = get_shipping_options($product_id);
if ($shipping_values != 'none') {
    ?>
	<table class="shipping-table">
		<tr>
			<td class="shipping-label"><?php 
    echo $single_names['product_shipping'];
    ?>
</td>
		</tr>
		<tr>
			<td>
				<ul><?php 
    foreach ($shipping_values as $i => $shipping_value) {
        $shipping_value = price_format($shipping_value);
        if (!empty($shipping_value)) {