Skip to main content

Hi all,

I’ll start by listing my steps, as I’ve forgotten to do so my last few posts.

 

(START OF CODE FOR STEP 3)

import re

 

description = inputData.get('description', '')

 

# Enhanced size codes including new ones (case sensitive)

size_codes = [

    'AXL', 'YSM', 'YXL', 'A2XL', 'AXS', 'W2XL', 'ALG', 'AMD', 'ASM', 'A2X', 'WXL',

    'YMD', 'A3XL', 'A4XL', 'A3X', 'A4X', 'WXS', 'WSM', 'WMD', 'WLG', 'W3XL', 'W4XL', 'YLG'

]

 

# Color codes to recognize (case insensitive matching)

color_codes = [

    'ATHLETIC HEATHER', 'Grey Concrete', 'MAROON', 'CHARCOAL', 'HEATHERED NAVY', 'DENIM',

    'IVORY', 'GREY', 'NAVY', 'BLACK', 'LIGHT BLUE', 'OXFORD', 'Athletic Heather Grey',

    'Dark Heather Grey', 'CAROLINA BLUE', 'GREY CONCRETE HEATHER', 'Heathered Red',

    'RAINBOW', 'PINK', 'White', 'Butter', 'Chalky Mint', 'Crunchberry', 'Lagoon',

    'Melon', 'Granite', 'GOLD', 'LAVENDER', 'PURPLE', 'HEATHERED PURPLE', 'Crimson',

    # Additional common colors

    'RED', 'BLUE', 'GREEN', 'YELLOW', 'ORANGE', 'BROWN', 'TAN', 'BEIGE', 'KHAKI',

    'FOREST GREEN', 'ROYAL BLUE', 'BURGUNDY', 'SILVER', 'CORAL', 'MINT', 'SAGE',

    'PEACH', 'CREAM', 'SAND', 'STONE', 'SLATE', 'TEAL', 'TURQUOISE'

]

 

found_sizes = []

remaining_text = str(description)

 

# Find and remove ALL size codes (case sensitive) using exact word boundaries

for size in size_codes:

    # Use word boundaries to match exact size codes, not partial matches

    pattern = r'\b' + re.escape(size) + r'\b'

    matches = re.findall(pattern, str(description))

    count = len(matches)

    if count > 0:

        found_sizes.extend([size] * count)

        # Remove size from remaining text using word boundaries

        remaining_text = re.sub(pattern, '', remaining_text)

        remaining_text = remaining_text.strip()

 

# Find ALL recognized colors in remaining text (case insensitive) - count duplicates

found_colors = []

for color in color_codes:

    count = remaining_text.upper().count(color.upper())

    if count > 0:

        found_colors.extend([color] * count)

 

# Size output: join all found sizes with commas, or empty string if none

size_output = ', '.join(found_sizes) if found_sizes else ''

 

# Color output: join all found colors with commas, or use remaining text if none found

color_output = ', '.join(found_colors) if found_colors else remaining_text

 

output = {'size': size_output, 'color': color_output}

(END OF CODE)

 


Those are my steps and the configurations. Here is my issue:

Below is my wix order I am using as an example.



Now, this is what is being output into my spreadsheet.

The webhook does gather the right data, and the spreadsheet DOES gather all the right size and color data, but I’m not sure how to code it or do a step that puts said data into the right row. I need each item to have one size and one color, or neither like the duffel which lacks options. But I’m not sure how to go about that… every modification I make to the loop or the code leaves the spreadsheet with no size or data input, or sometimes with no item names at all. 

Hi ​@Tylercwork 

Provided screenshots do not show how the Zap Code step inputs are configured, which could be a contributing factor to the issue.

 

Another issue to address is whether you have variables mapped correctly in the Looping step as the screenshot below shows many with the yellow warning indicating either variables that are not mapped correctly or variables that are not returned from the Zap trigger step for the selected example record.

 

 


Hi ​@Troy Tessalone,

I have removed the irrelevant and broken values.

 

It provides the same functionality as before. The looped values were calling for fields in the WIX webhook that did not exist, so they weren’t doing anything at all.

 

Here is how the code is configured as of now. Apologies for not including that to begin with.

Edit: The yellow in the input data of the code is because I hadn’t tested the steps when I took the screenshot. After testing, it is now gone.


@Tylercwork 

Screenshot for Zap step 3 Code Python shows an input variable mapped that is invalid from Zap step 2.

Make sure to test Zap step step and remap the variable for Item Description.

 


@Troy Tessalone I have tested and the invalid input variable was resolved. Same result is given when sending a test order to be mapped onto the spreadsheet.


@Tylercwork 

Try asking ChatGPT to help review and optimize your Python Code.

Check the DATA IN/OUT for each step when testing the Zap step config.

For live Zap Runs, check the DATA IN/OUT for each step to trace the data flow and troubleshoot: https://zapier.com/app/history/