Question

How do I map and extract data from WooCommerce to Xero based on specific conditions?

  • 27 July 2023
  • 7 replies
  • 101 views

Hi All,

I’m fairly new to Zapier and think this is probably going to be quite simple, but I’m not sure what to search for to find a help article. I am sending data from WooCommerce (new completed order) to Xero (New Sales Invoice). One of the fields I am passing is some meta data from our events booking plugin, Amelia. Our customers are booking weekly classes in historical fencing. Each of the classes is generally known, but there is some unknown variation.

For example;

Input Output
Class Name Weapon
Longsword Longsword
Longsword - Beginners Course Longsword
Longsword (reserved) Longsword
Park Sparring Other
Rapier Rapier
Sabre Sabre
Sabre -( Grappling  session) Sabre
Sabre (Including New Starters) Sabre

 

What I am after is a mapping step such that if any of the possible values for “Weapon” are contained in the string for “Class Name” then to Output that weapon, otherwise to Output “Other”. Can someone point me in the right direction for how to do this?

Dan


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

7 replies

Userlevel 7
Badge +14

Hi @powelly0 

Good question.

Try using this Zap action: Formatter > Utilities > Lookup Table

It handles line items.

https://help.zapier.com/hc/en-us/articles/8496305146765

Thanks @Troy Tessalone, however I think a lookup table would require all of the possible values to be known, whereas there will be new values created which will follow the same rules, but all possible values cannot be known in advance.

Userlevel 7
Badge +14

@powelly0 

You would likely need to create some sort of logic to apply or lookup table to reference.

I was going to propose just taking the first word of the INPUT, but there’s an exception...Park Sparring > Other

Plus, you’ve mentioned there are more options on the list and that those options can shrink/grow/change.

 

Yes, the logic is if INPUT string contains any of the values in a list (Sabre, Rapier, Longsword; non-case sensitive) then return that list item, else return “Other”. But I don’t know what tools to use to set up this logic in zapier.

Userlevel 7
Badge +14

@powelly0 

Why not simply update the Lookup Table once the new values are added/removed/changed?

however I think a lookup table would require all of the possible values to be known, whereas there will be new values created which will follow the same rules, but all possible values cannot be known in advance.

It’s an option, but would require a good deal of maintenance because of the volumes. The above table is just a small sample of possible values.

Since we do have a logical rule, there must be a way of implementing it? The logic is;

IF INPUT contains (x or y or z) then return z/y/z, respectively. 

Maybe something can be done with wildcards in a find and replace? 

Userlevel 7
Badge +14

@powelly0

Here’s what you probably want to do...manage this in WooCommerce with Categories, Tags, or Attributes.

https://woocommerce.com/document/managing-product-taxonomies/

 

That will likely eliminate the need to do lookups since the desired values would already be set in WC.

 

OTHERWISE

Some factors you are dealing with:

  1. 1 WooCommerce Order could have multiple line items
  2. You are trying to do partial matching (INPUT/OUTPUT)
    1. So logic becomes more complex
  3. You need to output a new RESULTS data array (list of matched OUTPUTS) to be used in Xero
    1. Note: Xero may expect an internal Item ID instead of the friendly Item name
  4. There could be multiple matches for 1 INPUT Class Name from the WooCommerce Order
    1. For example (hypothetical)
      1. If WooCommerce Order has a line item with Class Name of “Longsword & Sabre”
      2. That matches to 2 results based on your conditions:
        1. Longsword
        2. Sabre
      3. So now you have 2 results for 1 WooComerce Order line item
  5. You need logic to determine how to handle multiple matches for 1 WC Order line item in the new RESULTS data array
    1. First match
    2. Last match

 

This logic has to be defined, managed, and applied somewhere:

IF INPUT contains (x or y or z) then return z/y/z, respectively. 

 

If the list is going to change (add/remove/edit) over time, then you need to come up with a solution that will work with the changes.