• I was wondering if it would be possible to create a field for a product summary report that loops through products and sums up a custom meta data field, kind of like how the field “Summary Report Total Amount” sums up the accumulative prices of a particular product.

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

    (@algolplus)

    Hello

    do you want to sum Product meta or Order Item meta?

    1. add new key using >Setup Fields>Add Field
    2. add extra code to seciotn “Misc Settings”

    Here is example,
    You should call $product->get_meta() or $item->get_meta() to read necessary values.

    // I added key "summary_qty_minus_refund" to export 
    add_action('woe_summary_products_add_item',function ($key, $item, $order) {
      $product = $item->get_product();
      $_SESSION['woe_summary_products'][$key]['summary_qty_minus_refund'] += ($item['qty'] + $order->get_qty_refunded_for_item( $item->get_id() ) );
    },10,3);
    Thread Starter mkepli01

    (@mkepli01)

    I think it would be order item meta, we currently get the meta in our order summary sheets using the code

    add_filter('woe_get_order_product_value_field_name', function ($value, $order, $item, $product,$item_meta) {
    
    $value =  $item_meta['_meta_name']; 
    
       return $value;
    }, 10, 5);

    So would I do $Value = $item->get_meta('_meta_name')?

    Plugin Author algol.plus

    (@algolplus)

    yes, it should work.

    but you must debug it , add some var_dumps() and press Preview

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Summary field for custom item meta’ is closed to new replies.