• Resolved cmsnext

    (@cmsnext)


    Hi,
    You had helped me out with splitting values earlier. Now I have added a new Product order Item meta and facing some minor issue.

    I go to Product order items > Add field > Order item fields: From the drop down I select the field I want which is called Measurement in the drop down.

    So now the csv does display the field correctly but is also adding some json like value. Is it possible to split this to custom columns before display?

    Right now the column value shows for example

    a:3:{i:0;s:4:"200";i:1;s:3:"300";i:2;s:3:"400";}, 200 x 300 x 400

    So what I now want is

    have 3 custom columns
    Measurement_1, Measurement_2 Measurement_3

    and display

    200 300 400 as value under each column

    Any idea how it can be done?

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

    (@algolplus)

    Hello

    could you run phpMyAdmin, open wp_woocommerce_order_itemmeta , find meta_key = Measurement and send me meta_value ?

    thanks, Alex

    Thread Starter cmsnext

    (@cmsnext)

    Hi,
    It seems to be creating two rows.

    First Row shows

    a:3:{i:0;s:4:"200";i:1;s:3:"300";i:2;s:3:"400";}

    and second row shows

    200 x 300 x 400

    So basically what we need is get the row with the second row type content for each order_item_id and then split it to individual columns

    Plugin Author algol.plus

    (@algolplus)

    What plugin adds this meta?

    Thread Starter cmsnext

    (@cmsnext)

    Custom coded by a developer. Not any plugin but has been custom coded to fetch and add this meta to product order

    Plugin Author algol.plus

    (@algolplus)

    ok, got it.

    please, follow to https://docs.algolplus.com/algol_order_export/add-calculated-field-for-product/
    add keys Measurement_1, Measurement_2 Measurement_3
    use this code

    add_filter( 'woe_fetch_order_product', function($row, $order, $item, $product, $item_meta ){
      $data = $item->get_meta("Measurement"); 
      if( is_array($data) ) {
        $row['Measurement_1'] = $data[0];
        $row['Measurement_2'] = $data[1];
        $row['Measurement_3'] = $data[2];
      }
      return $row;
    },10,5);
    Thread Starter cmsnext

    (@cmsnext)

    Perfect. Works as expected. Thanks a lot for your support

    Plugin Author algol.plus

    (@algolplus)

    you’re very welcome

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Query regarding Product order items modifying value’ is closed to new replies.