Ejemplo n.º 1
0
/**
 * @param fflcommerce_order $order
 * @return string
 */
function fflcommerce_get_order_taxes_list($order)
{
    $taxes = '';
    foreach ($order->get_tax_classes() as $tax_class) {
        $taxes .= sprintf(_x('%s (%s%%): %.4f', 'emails', 'fflcommerce'), $order->get_tax_class_for_display($tax_class), $order->get_tax_rate($tax_class), $order->get_tax_amount($tax_class)) . PHP_EOL;
    }
    return $taxes;
}
function fflcommerce_custom_order_columns($column)
{
    global $post;
    $fflcommerce_options = FFLCommerce_Base::get_options();
    $order = new fflcommerce_order($post->ID);
    switch ($column) {
        case "order_status":
            echo sprintf('<mark class="%s">%s</mark>', sanitize_title($order->status), __($order->status, 'fflcommerce'));
            break;
        case "order_title":
            echo '<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '">' . sprintf(__('Order %s', 'fflcommerce'), $order->get_order_number()) . '</a>';
            echo '<time title="' . date_i18n(_x('c', 'date', 'fflcommerce'), strtotime($post->post_date)) . '">' . date_i18n(__('F j, Y, g:i a', 'fflcommerce'), strtotime($post->post_date)) . '</time>';
            break;
        case "customer":
            if ($order->user_id) {
                $user_info = get_userdata($order->user_id);
            }
            ?>
            <dl>
                <dt><?php 
            _e('User:'******'fflcommerce');
            ?>
</dt>
                <dd><?php 
            if (isset($user_info) && $user_info) {
                echo '<a href="user-edit.php?user_id=' . $user_info->ID . '">#' . $user_info->ID . ' &ndash; <strong>';
                if ($user_info->first_name || $user_info->last_name) {
                    echo $user_info->first_name . ' ' . $user_info->last_name;
                } else {
                    echo $user_info->display_name;
                }
                echo '</strong></a>';
            } else {
                _e('Guest', 'fflcommerce');
            }
            ?>
</dd>
                <?php 
            if ($order->billing_email) {
                ?>
<dt><?php 
                _e('Billing Email:', 'fflcommerce');
                ?>
</dt>
                    <dd><a href="mailto:<?php 
                echo $order->billing_email;
                ?>
"><?php 
                echo $order->billing_email;
                ?>
</a></dd><?php 
            }
            ?>
                <?php 
            if ($order->billing_phone) {
                ?>
<dt><?php 
                _e('Billing Phone:', 'fflcommerce');
                ?>
</dt>
                    <dd><?php 
                echo $order->billing_phone;
                ?>
</dd><?php 
            }
            ?>
            </dl>
            <?php 
            break;
        case "billing_address":
            echo '<strong>' . $order->billing_first_name . ' ' . $order->billing_last_name;
            if ($order->billing_company) {
                echo ', ' . $order->billing_company;
            }
            echo '</strong><br/>';
            echo '<a target="_blank" href="http://maps.google.co.uk/maps?&q=' . urlencode($order->formatted_billing_address) . '&z=16">' . $order->formatted_billing_address . '</a>';
            break;
        case "shipping_address":
            if ($order->formatted_shipping_address) {
                echo '<strong>' . $order->shipping_first_name . ' ' . $order->shipping_last_name;
                if ($order->shipping_company) {
                    echo ', ' . $order->shipping_company;
                }
                echo '</strong><br/>';
                echo '<a target="_blank" href="http://maps.google.co.uk/maps?&q=' . urlencode($order->formatted_shipping_address) . '&z=16">' . $order->formatted_shipping_address . '</a>';
            } else {
                echo '&ndash;';
            }
            break;
        case "billing_and_shipping":
            ?>
            <dl>
	              <?php 
            if ($order->payment_method_title) {
                ?>
                <dt><?php 
                _e('Payment:', 'fflcommerce');
                ?>
</dt>
                <dd><?php 
                echo $order->payment_method_title;
                ?>
</dd>
	              <?php 
            }
            ?>
	              <?php 
            if ($order->shipping_service) {
                ?>
                <dt><?php 
                _e('Shipping:', 'fflcommerce');
                ?>
</dt>
                <dd><?php 
                echo sprintf(__('%s', 'fflcommerce'), $order->shipping_service);
                ?>
</dd>
	              <?php 
            }
            ?>
            </dl>
            <?php 
            break;
        case "total_cost":
            ?>
            <table cellpadding="0" cellspacing="0" class="cost">
                <tr>
                    <?php 
            if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes' && $order->has_compound_tax() || $fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) {
                ?>
                        <th><?php 
                _e('Retail Price', 'fflcommerce');
                ?>
</th>
                    <?php 
            } else {
                ?>
                        <th><?php 
                _e('Subtotal', 'fflcommerce');
                ?>
</th>
                    <?php 
            }
            ?>
                    <td><?php 
            echo fflcommerce_price($order->order_subtotal);
            ?>
</td>
                </tr>
                <?php 
            if ($order->order_shipping > 0) {
                ?>
<tr>
                        <th><?php 
                _e('Shipping', 'fflcommerce');
                ?>
</th>
                        <td><?php 
                echo fflcommerce_price($order->order_shipping);
                ?>
</td>
                    </tr>
                    <?php 
            }
            do_action('fflcommerce_processing_fee_after_shipping');
            if ($fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) {
                ?>
                    <tr>
                        <th><?php 
                _e('Discount', 'fflcommerce');
                ?>
</th>
                        <td>-<?php 
                echo fflcommerce_price($order->order_discount);
                ?>
</td>
                    </tr>
                    <?php 
            }
            if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes' && $order->has_compound_tax() || $fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) {
                ?>
<tr>
                        <th><?php 
                _e('Subtotal', 'fflcommerce');
                ?>
</th>
                        <td><?php 
                echo fflcommerce_price($order->order_discount_subtotal);
                ?>
</td>
                    </tr>
                    <?php 
            }
            if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes') {
                foreach ($order->get_tax_classes() as $tax_class) {
                    if ($order->show_tax_entry($tax_class)) {
                        ?>
                            <tr>
                                <th><?php 
                        echo $order->get_tax_class_for_display($tax_class) . ' (' . (double) $order->get_tax_rate($tax_class) . '%):';
                        ?>
</th>
                                <td><?php 
                        echo $order->get_tax_amount($tax_class);
                        ?>
</td>
                            </tr>
                            <?php 
                    }
                }
            }
            if ($fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'no' && $order->order_discount > 0) {
                ?>
<tr>
                        <th><?php 
                _e('Discount', 'fflcommerce');
                ?>
</th>
                        <td>-<?php 
                echo fflcommerce_price($order->order_discount);
                ?>
</td>
                    </tr><?php 
            }
            ?>
                <tr>
                    <th><?php 
            _e('Total', 'fflcommerce');
            ?>
</th>
                    <td><?php 
            echo fflcommerce_price($order->order_total);
            ?>
</td>
                </tr>
            </table>
            <?php 
            break;
        case 'order_coupons':
            if (!empty($order->order_discount_coupons)) {
                foreach ($order->order_discount_coupons as $used_coupon) {
                    ?>
			           <p class="order_coupon"><?php 
                    echo '#' . $used_coupon['id'] . ' - ' . $used_coupon['code'];
                    ?>
</p>
				<?php 
                }
            }
            break;
    }
}