Skip to content

Instantly share code, notes, and snippets.

@NazarenkoDenis
Last active March 29, 2024 12:03
Show Gist options
  • Save NazarenkoDenis/d1db9139c83efcbf4e475fd3a805e42e to your computer and use it in GitHub Desktop.
Save NazarenkoDenis/d1db9139c83efcbf4e475fd3a805e42e to your computer and use it in GitHub Desktop.
VAR l_from_variant_name = convert(regexp_match(order_items.variant_name, '\d{2,4}'), INT)
VAR l_from_props = convert(case(
not(is_empty(json_path(order_items.properties, "#(name=""Custom Length"").value"))), json_path(order_items.properties, "#(name=""Custom Length"").value"),
not(is_empty(json_path(order_items.properties, "#(name=""Wunschlänge"").value"))), json_path(order_items.properties, "#(name=""Wunschlänge"").value"),
not(is_empty(json_path(order_items.properties, "#(name=""Longueur sur mesure"").value"))), json_path(order_items.properties, "#(name=""Longueur sur mesure"").value"),
not(is_empty(json_path(order_items.properties, "#(name=""Aangepaste lengte"").value"))), json_path(order_items.properties, "#(name=""Aangepaste lengte"").value"),
not(is_empty(json_path(order_items.properties, "#(name=""Expédié après"").value"))), json_path(order_items.properties, "#(name=""Expédié après"").value"),
not(is_empty(json_path(order_items.properties, "#(name=""Anpassad längd"").value"))), json_path(order_items.properties, "#(name=""Anpassad längd"").value"),
not(is_empty(json_path(order_items.properties, "#(name=""Lunghezza personalizzato"").value"))), json_path(order_items.properties, "#(name=""Lunghezza personalizzato"").value"),
not(is_empty(json_path(order_items.properties, "#(name=""Wunschlänge in cm"").value"))), json_path(order_items.properties, "#(name=""Wunschlänge in cm"").value"),
0
), INT)
RETURN if(l_from_variant_name > 0, l_from_variant_name, l_from_props)
@zentmipler
Copy link

VAR l_from_variant_name = convert(regexp_match(order_items.variant_name, '\d{2,4}'), FLOAT)
VAR l_from_props = convert(case( 
	not(is_empty(json_path(order_items.properties, "#(name=""Custom Length"").value"))), json_path(order_items.properties, "#(name=""Custom Length"").value"),
	not(is_empty(json_path(order_items.properties, "#(name=""Wunschlänge"").value"))), json_path(order_items.properties, "#(name=""Wunschlänge"").value"),
	not(is_empty(json_path(order_items.properties, "#(name=""Longueur sur mesure"").value"))), json_path(order_items.properties, "#(name=""Longueur sur mesure"").value"),
	not(is_empty(json_path(order_items.properties, "#(name=""Aangepaste lengte"").value"))), json_path(order_items.properties, "#(name=""Aangepaste lengte"").value"),
	not(is_empty(json_path(order_items.properties, "#(name=""Expédié après"").value"))), json_path(order_items.properties, "#(name=""Expédié après"").value"),
    not(is_empty(json_path(order_items.properties, "#(name=""Anpassad längd"").value"))), json_path(order_items.properties, "#(name=""Anpassad längd"").value"),
    not(is_empty(json_path(order_items.properties, "#(name=""Lunghezza personalizzato"").value"))), json_path(order_items.properties, "#(name=""Lunghezza personalizzato"").value"),
    not(is_empty(json_path(order_items.properties, "#(name=""Wunschlänge in cm"").value"))), json_path(order_items.properties, "#(name=""Wunschlänge in cm"").value"),
    not(is_empty(json_path(order_items.properties, "#(name=""Longitud Personalizado"").value"))), json_path(order_items.properties, "#(name=""Longitud Personalizado"").value"),
	not(is_empty(json_path(order_items.properties, "#(name=""Longeur sur mesure"").value"))), json_path(order_items.properties, "#(name=""Longeur sur mesure"").value"),
    not(is_empty(json_path(order_items.properties, "#(name=""Longueur Sur Mesure"").value"))), json_path(order_items.properties, "#(name=""Longueur Sur Mesure"").value"),
    not(is_empty(json_path(order_items.properties, "#(name=""Custom Length in cm"").value"))), json_path(order_items.properties, "#(name=""Custom Length in cm"").value"),
    not(is_empty(json_path(order_items.properties, "#(name=""Aangepaste lengte in cm"").value"))), json_path(order_items.properties, "#(name=""Aangepaste lengte in cm"").value"),
    not(is_empty(json_path(order_items.properties, "#(name=""Lunghezza desiderata in CM"").value"))), json_path(order_items.properties, "#(name=""Lunghezza desiderata in CM"").value"),
    not(is_empty(json_path(order_items.properties, "#(name=""Longitud personalizada"").value"))), json_path(order_items.properties, "#(name=""Longitud personalizada"").value"),
    0 
), FLOAT)

RETURN if(l_from_variant_name > 0, l_from_variant_name, l_from_props)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment