• Hi team, a few weeks ago you helped me in adding the SKU field to the invoice plugin. This works perfectly.

    Now I am wondering whether it is also possible to include the “tag” field on this invoice? https://snipboard.io/L0pz5K.jpg

    Many thanks!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter gossie

    (@gossie)

    hello, did you have time to have a look at this request please?

    Plugin Author YITHEMES

    (@yithemes)

    Hello there,

    hope you are doing well ??

    To add the product tags in the invoice you have to replace the last snippet of code we gave you with the following one:

    $order_items = $ywpi_document->order->get_items ();
    
    foreach ( $order_items as $item_id => $item ) {
        if ( isset( $item['qty'] ) ) {
            $price_per_unit = $item['line_subtotal'] / $item['qty'];
            $price_per_unit_sale = $item['line_total'] / $item['qty'];
            $discount = $price_per_unit - $price_per_unit_sale;
        }
    
        $tax = $item['line_tax'];
    
        $product = wc_get_product( $item['product_id'] );
    
        ?>
            <tr>
                <td class="column-product"><?php echo $item['name']; ?>
                    <br>
                    <?php echo "SKU: " . $product->get_sku(); ?>
                    <br>
                    <?php echo 'Tag: ' . wc_get_product_tag_list( $product->get_id(), ', ' ); ?>
                </td>
                <td class="column-quantity"><?php echo ( isset( $item['qty'] ) ) ? esc_html ( $item['qty'] ) : ''; ?></td>
            </tr>
    <?php };

    Try it and let us know any news, please.

    Have a nice day!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add product tag to invoice’ is closed to new replies.