• Resolved Pierre Mathelin

    (@pierreuniqode)


    Hi there,

    I use the Unit Price for WooCommerce plugin for my online shop which sells food.
    The plugin is used to display product price in kg and that works well! you can see the result bellow: https://lagrandeboucheriedesquais.com/shop/

    However, I need to display the product price per kg in the generated invoice.
    For the invoices, I use PDF Invoices & Packing Slips for WooCommerce but I only have “classic” products prices.

    Do you have any suggestion how to also display the product price per kg in the invoices? An parameter or custom to do in the plugin?

    Thanks a lot for your support!

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Darren Peyou

    (@dpeyou)

    Hello @pierreuniqode,

    Do you know if these fields are stored in the order?
    You could follow the guide here to find WooCommerce hidden custom fields…
    Finding WooCommerce Custom Fields
    …then go to the product’s page in the backend to see the meta-keys of the product. This will give us a hint on what information we can potentially use to display this price. All solutions would involve custom code. ??

    Hi Pierre and Darren,
    The product price in kg is actually the order item cost, which can be displayed in the template using:
    echo wc_price( $order->get_item_subtotal( $item, false, true ), array( 'currency' => $order->get_currency() ) );

    Thread Starter Pierre Mathelin

    (@pierreuniqode)

    Hi Darren, hi Condless,

    I finally figured out how to get what I need.
    To explain you (and for other people interested) further my needs:
    – I need to get price by kg (as mentionned in the topic)
    – I also needed to get pickup datetime displayed on the invoice (plugin XXX)

    To do so, I finally figured out there was an option to display quantity with the premium plugin (which like Condless said, is the order item cost), so this what easily solved whit the invoice configurator.

    However, to display pickup datetime it was a bit tricky. The order data I could normally used for it is, as I understood, {{local_pickup_plus_pickup_details}}.
    Usually you just have to create a text block in the invoice configurator but in my case nothing is displayed. I don’t know if it is a plugin issue or a misconfiguration on my side.
    the solution I found was to create my own template by copy-pasting a template into my custom theme (woocommer/pdf/template/mytemplate) and then add the following code:

    <table>
        <tbody>
            <?php foreach ( $this->get_woocommerce_totals() as $key => $total ) : ?>
                <tr class="<?php echo esc_attr( $key ); ?>">
                    <th class="description"><?php echo esc_html( $total['label'] ); ?></th>
                    <td class="price"><span class="totals-price"><?php echo wp_kses_post( $total['value'] ); ?></span></td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>

    the bad side on that is that you cannot use the invoice configurator for the totals but that’s the only working solution I found for now. (If you have any solution to make the order data work I am interested ??)

    Thanks you two Darren and Condless for your help.
    I hope this post will help other people there.

    • This reply was modified 2 years, 1 month ago by Pierre Mathelin. Reason: Code formatting
    • This reply was modified 2 years, 1 month ago by Pierre Mathelin. Reason: Code formatting
    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @pierreuniqode,

    Since you mentioned the “invoice configurator”, I guess that you have Premium Templates, therefore, we can provide you with further help in our premium support channel. Please write us by [email protected], and we’ll do our best to achieve what you want ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display price per kg in customer invoice’ is closed to new replies.