1 year ago

#363876

test-img

titia2478

Display shipping for each products on invoice - Woocommerce

I want to show a shipping row on invoice because I use the plugin "Multiple Packages for WooCommerce". Indeed for each product the customer can choose "livraison express (25€)" or "Livraison Franco de port" (0€).

Currently my invoice looks like this enter image description here

So I wish it looked like this :

enter image description here

The shipping method above each products and only the amount of delivery in the row of total.

In the file "invoice.php", I Have this :

<tbody>
    <?php $items = $this->get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) : ?>
    <tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->type, $this->order, $item_id ); ?>">
        <td class="product">
            <?php $description_label = __( 'Description', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
            <span class="item-name"><?php echo $item['name']; ?></span>
            <?php do_action( 'wpo_wcpdf_before_item_meta', $this->type, $item, $this->order  ); ?>
            <span class="item-meta"><?php echo $item['meta']; ?></span>
            <dl class="meta">
                <?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
                <?php if( !empty( $item['sku'] ) ) : ?><dt class="sku"><?php _e( 'Référence :', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku"><?php echo $item['sku']; ?></dd><?php endif; ?></dl>
            <?php do_action( 'wpo_wcpdf_after_item_meta', $this->type, $item, $this->order  ); ?>
        </td>
        <td class="quantity"><?php echo $item['quantity']; ?></td>
        <td class="price"><?php echo $item['order_price']; ?></td>
    </tr>
    <?php endforeach; endif; ?>
</tbody>

So I try to add this code

<?php echo $order->get_shipping_to_display(); ?>

Like this

<dl class="meta">
                    <?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
                    <?php if( !empty( $item['sku'] ) ) : ?><dt class="sku"><?php _e( 'Référence :', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku"><?php echo $item['sku']; ?></dd><?php endif; ?>
                    <?php /*if( !empty( $item['weight'] ) ) : ?><dt class="weight"><?php _e( 'Weight:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="weight"><?php echo $item['weight']; ?><?php echo get_option('woocommerce_weight_unit'); ?></dd><?php endif;*/ ?>
                    <dt class="sku"><?php_e( 'Livraison :', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku">
                        <?php echo $order->get_shipping_to_display(); ?></dd></dl>

but i get this :

enter image description here

So I understand that this code call the shipping for the order and not for the item but if I try <?php echo $item->get_shipping_to_display(); ?> I have an error.

Is someone can help me?

wordpress

woocommerce

shipping-method

0 Answers

Your Answer

Accepted video resources