自定义woocommerce订单详细信息

时间:2014-03-26 11:11:58

标签: php wordpress woocommerce

在我的电子商务中,结帐页面显示了按名称排序的所有产品和表格中的总价格,如何在表格中添加产品类别? 我想要更改的页面是order-details.php,在此表中添加了类别过滤器:

<table class="shop_table order_details">
    <thead>
        <tr>
            <th class="product-name"><?php _e( 'Product', 'woocommerce' ); ?></th>
            <th class="product-total"><?php _e( 'Total', 'woocommerce' ); ?></th>
        </tr>
    </thead>
    <tfoot>
    <?php
        if ( $totals = $order->get_order_item_totals() ) foreach ( $totals as $total ) :
            ?>
            <tr>
                <th scope="row"><?php echo $total['label']; ?></th>
                <td><?php echo $total['value']; ?></td>
            </tr>
            <?php
        endforeach;
    ?>
    </tfoot>
    <tbody>
        <?php
        if (sizeof($order->get_items())>0) {

            foreach($order->get_items() as $item) {

                $_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );

                echo '
                    <tr class = "' . esc_attr( apply_filters( 'woocommerce_order_table_item_class', 'order_table_item', $item, $order ) ) . '">
                        <td class="product-name">' .
                            apply_filters( 'woocommerce_order_table_product_title', '<a href="' . get_permalink( $item['product_id'] ) . '">' . $item['name'] . '</a>', $item ) . ' ' .
                            apply_filters( 'woocommerce_order_table_item_quantity', '<strong class="product-quantity">&times; ' . $item['qty'] . '</strong>', $item );

                $item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
                $item_meta->display();

                if ( $_product->exists() && $_product->is_downloadable() && $order->is_download_permitted() ) {

                    $download_file_urls = $order->get_downloadable_file_urls( $item['product_id'], $item['variation_id'], $item );

                    $i     = 0;
                    $links = array();

                    foreach ( $download_file_urls as $file_url => $download_file_url ) {

                        $links[] = '<small><a href="' . $download_file_url . '">' . sprintf( __( 'Download file%s', 'woocommerce' ), ( count( $download_file_urls ) > 1 ? ' ' . ( $i + 1 ) . ': ' : ': ' ) ) . basename( $file_url ) . '</a></small>';

                        $i++;
                    }

                    echo implode( '<br/>', $links );
                }

                echo '</td><td class="product-total">' . $order->get_formatted_line_subtotal( $item ) . '</td></tr>';

                // Show any purchase notes
                if ($order->status=='completed' || $order->status=='processing') {
                    if ($purchase_note = get_post_meta( $_product->id, '_purchase_note', true))
                        echo '<tr class="product-purchase-note"><td colspan="3">' . apply_filters('the_content', $purchase_note) . '</td></tr>';
                }

            }
        }

        do_action( 'woocommerce_order_items_table', $order );
        ?>
    </tbody>
</table>

0 个答案:

没有答案