• Resolved pavelevap

    (@pavelevap)


    Hi,
    I tried to export custom meta_key which is added to shipping item in order.
    I can see it in database (in woocommerce_order_itemmeta), but when I tried to set up field in “Product order items” section, no values are visible in Preview. Maybe it is working only for product order items and ignoring shipping order item? Or I am missing something?
    Thank you very much for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author algol.plus

    (@algolplus)

    hi

    yes, this section works only for products.

    you should use this way
    https://algolplus.freshdesk.com/support/solutions/articles/25000016635-add-calculated-field-for-order-

    and use $order->get_items(‘shipping’) to get shipping order items

    thanks, Alex

    Thread Starter pavelevap

    (@pavelevap)

    Thank you very much for this hint. I did not notice this powerfull filter 🙁

    My example for my_custom_field:

    add_filter('woe_get_order_value_my_custom_field',function ($value,$order,$fieldname) {
      if ( $order->has_shipping_method( 'custom_shipping_method' ) ) {
        foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) {
          $point = wc_get_order_item_meta( $shipping_item_id, 'my_custom_field', true );
          if ( ! empty( $point ) ) {
            $value = $point;
          }
        }
      }
      return $value;
    },10,3);

    Works like a charm! 🙂

    Plugin Author algol.plus

    (@algolplus)

    you’re very welcome.

    and thank you for the code!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Export shipping order item meta’ is closed to new replies.