Best answer

Woocommerce meta data field

  • 21 April 2020
  • 3 replies
  • 996 views

Userlevel 1

The old Zapier and Woocommerce integration divided each meta data field as separate field for further processing. Now all our meta data fields are together like this 

+37255616160,no,et,0,orddd_location_1,Tööstuse 47b,01/05/20,1588291200,09:00 - 12:00,09:00 - 12:00,1588323600,ee_nordea,4afb1678-ee35-4f03-9959-01feb6eb7835,1

How can we use and further process only the data we need - 01/05/20 (date) & 09:00 - 12:00 (time)?

Played around with text splitter but it didn’t work. Feeling a little bit desperate now as I have to put all the dates and time slots to our orders manually :(

 

 

icon

Best answer by bradleyputters 22 April 2020, 00:31

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 1

This solved it for me. hhttps://om4.io/woocommerce-zapier-documentation/usage/#add-meta-data-fields-to-a-trigger

Userlevel 1

This solved it for me. hhttps://om4.io/woocommerce-zapier-documentation/usage/#add-meta-data-fields-to-a-trigger

For me also, thanks! :)

Userlevel 3
Badge

There is another way - rather than adding meta data fields to a trigger and triggering on line items, you can take the meta data and the line items and parse them directly. Different WooCommerce plugins handle metadata in different ways - some of them very convoluted. Here’s what I get from one of my sites:

meta_data
id: 99017
key: is_vat_exempt
value: no
id: 99018
key: thwcfe_ship_to_billing
value: 0
id: 99019
key: _thwcfe_disabled_fields
value: location_name
id: 99020
key: fl_venue
value: caci
id: 99021
key: shipping_address_1
value: 101 Main Rd
id: 99022
key: shipping_city
value: Cathedral City
id: 92234
key: cust_name
value: TEST ORDER
id: 99024
key: folio_id
value: TEST ORDER
id: 99025
key: fl_delivery_date
value: Jun 12, 20
id: 99026
key: fl_delivery_time
value: 06:00 PM
id: 99027
key: fl_delivery_instructions
value: TEST ORDER - DO NOT FILL

When I get this from my webhook, I parse the string like this:

var temp_meta = JSON.parse(items[j].meta_data.replace(/: False/g, ': false').replace(/\\xa/g, '').replace(/"/g,'~~~').replace(/'/g,'"').replace(/~~~/g,'"').replace(/\/xa/g, ''));
options_array = temp_meta;
options_array.splice(0,4);
var options_text_block = '';
var calendar_options_text_block = '';
for (var k=0; k < options_array.length; k++) {
var temp_option = options_array[k];
if (temp_option.key.substring(0,1) == '_'){
continue;
}
key = temp_option.key;
value = temp_option.value;
options_text_block += key + ': ' + value + os.EOL;
calendar_options_text_block += key + ': ' + value + line_end;
if (key == "Colors"){
items[j].color_option = "Colors: " + value;
}
}

And yes, it could be more elegant - but it works.

You can take a similar approach to line items (“raw_data” is the lines field):

var lines_array = raw_data.split(os.EOL+os.EOL);

It’s a bit of trouble, I agree - but a simple un-edited webhook on new order works nicely, and by parsing the meta in this way you can accommodate plugins with, well, “interesting” approaches.