Support » Plugin: WooCommerce PDF Invoices & Packing Slips » From order item post meta

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Ewout

    (@pomegranate)

    there’s a difference between order item meta and order meta. Your post subject says order item post meta, you have to use wc_get_order_item_meta and can find more about that here: https://wordpress.org/support/topic/order-items-post-meta/#post-9625892

    for order meta your code is fine as is. I don’t know how UTF-8 permissive WooCommerce is when it comes to order meta though.

    I didn’t understand. Should my code look like this? Does not work
    <?php echo $order-> wc_get_order_item_meta('Валюта'); ?>

    Plugin Author Ewout

    (@pomegranate)

    No it’s not an order method but a regular function. Check the post I linked to for an example. This is specifically for order item meta though, not order meta.

    Yes, thanks, it works. Nearly. Why doesn’t this field show
    <?php echo wc_get_order_item_meta( $item['item_id'], '1-ый ФИО русскими буквами', true ); ?>

    Plugin Author Ewout

    (@pomegranate)

    THe only reason I can think of is that this is outside the order items table which would mean the item_id is not set. This should always be done inside a loop of order items because there can be multiple items in an order.

    Like this?
    `<?php
    $items = $this->get_order_items();
    if( sizeof( $items ) > 0 ) {
    foreach( $items as $item ) {
    if (isset($item[‘item’][‘item_meta’][‘1-ый ФИО русскими буквами’])) {
    $nomer = wc_get_order_item_meta( $item[‘item_id’], ‘1-ый ФИО русскими буквами’, true );}

    }}

    ?>

    Plugin Author Ewout

    (@pomegranate)

    without the if (isset($item['item']['item_meta']['1-ый ФИО русскими буквами'])) this may work (don’t forget to echo the $nomer value too). But I don’t know your setup, this is too specific for these forums. If you need more coding help I recommend hiring a developer.

    Very strange. This code works
    $tele = wc_get_order_item_meta( $item['item_id'], 'Телефон', true );}

    And this one doesn’t work

    $strah1 = wc_get_order_item_meta( $item['item_id'], '1-й ФИО русскими буквами', true );

    Plugin Author Ewout

    (@pomegranate)

    It’s a woocommerce function, so if you think it’s a bug I recommend reaching out to them. Like I said, I’m not sure how permissive WooCommerce is with UTF-8 meta keys…

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.