Best answer

Extract Values from Text – BigCommerce Product Options

  • 4 December 2022
  • 4 replies
  • 38 views

I’m trying to extract 3 values from BigCommerce custom product options. Each product will have these 3 options: 

  • Learner First Name 
  • Learner Last Name
  • Learner Email Address

I was able to use the “Extract Email Address” function in the Zapier Formatter, and that is working well. I’m having trouble extracting the other two values, though. The data is coming through like this:

 

item_1:
display_name: Learner First Name
display_name_customer: Learner First Name
display_name_merchant: Learner First Name
display_style:
display_value: Jonathan
display_value_customer: Jonathan
display_value_merchant: Jonathan
id: 16
name: Learner First Name
option_id: 33
order_product_id: 17
product_option_id: 155
type: Text field
value: Jonathan
display_name: Learner Last Name
display_name_customer: Learner Last Name
display_name_merchant: Learner Last Name
display_style:
display_value: May
display_value_customer: May
display_value_merchant: May
id: 17
name: Learner Last Name
option_id: 34
order_product_id: 17
product_option_id: 156
type: Text field
value: May

 

I just need the 2 “value” fields, but I need to know which option the value is associated with - Learner First Name or Learner Last Name. 

icon

Best answer by Troy Tessalone 4 December 2022, 22:01

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.

4 replies

Userlevel 7
Badge +14

Hi @jonathanisaac 

Good question.

Can you post a screenshot with how the returned data is structured for clarity?

Looks like there are 2 sets of data related to each field.

 

You can try using Formatter > Text > options to isolate the desired value.

Otherwise, a custom Code step can be used.

 

First Name

 

Last Name

 

Here are the screenshots. Since both values have the same label (“value:”), how would you recommend isolating them separately? 

Userlevel 7
Badge +14

@jonathanisaac 

Try this JavaScript Code step...

 

Input

 

Code

let Learner = inputData.Learner;
Learner = Learner.split("\n");

Learner = Learner.filter(i => i.includes("display_value:"));

let LearnerNameFirst = Learner[0].split(": ")[1];
let LearnerNameLast = Learner[1].split(": ")[1];

output = [{LearnerNameFirst, LearnerNameLast, Learner}];

 

Output

 

Thank you so much! That did the trick!