What is your goal?
I receive the RUT (Chilean tax ID) from customers via Shopify—they store it in the “ZIP” or “Company” field, as the checkout process doesn’t have a dedicated RUT field—and I need to send it to my invoicing system in the full Chilean format: 16.012.312-4.
What is the problem & what have you tried?
In the (now closed) thread “Chilean RUT (DNI) Format,” the suggested solution added the hyphen but not the dots. I came up with this approach, in case it’s useful to anyone else:
Clean the value using a “Set variable” module (rut_limpio):
{{upper(replace(1.zip; /[^0-9kK]/g; emptystring))}}
Apply the format:
{{replace(substring(rut_limpio; 0; length(rut_limpio) - 1); /\B(?=(\d{3})+(?!\d))/g; “.”)}}-{{substring(rut_limpio; length(rut_limpio) - 1; length(rut_limpio))}}
Result: 160123124 → 16.012.312-4; this also works when the check digit is “K.”
What I’m still missing: validating the check digit (using the “modulo 11” algorithm) before sending the data, as customers frequently make typos when entering it. Has anyone managed to do this using only native Make functions—without relying on a code module or an external API? The tricky part is iterating through the digits and multiplying them by 2, 3, 4, 5, 6, and 7.
What is your goal?
I receive the RUT from customers via Shopify (they save it in the ZIP or Company field because the checkout doesn’t have a specific RUT field), and I need to send it to my billing system in the complete Chilean format: 16.012.312-4.
What is the problem & what have you tried?
In the “Chilean RUT (DNI) Format” topic (now closed), the proposed solution added the hyphen but not the dots. I solved it this way, in case it’s useful to anyone else:
- Clean the value using a “Set variable” module (rut_limpio):
{{upper(replace(1.zip; /[^0-9kK]/g; emptystring))}}
- Apply formatting:
{{replace(substring(rut_limpio; 0; length(rut_limpio) - 1); /\B(?=(\d{3})+(?!\d))/g; “.”)}}-{{substring(rut_limpio; length(rut_limpio) - 1; length(rut_limpio))}}
Result: 160123124 → 16.012.312-4, and it works when the check digit is K.
What I’m still missing: validating the check digit (modulo 11) before sending it, since customers often make mistakes when typing it. Has anyone done this using only native Make functions—without using a code module or an external API? The tricky part is iterating through the digits and multiplying them by 2, 3, 4, 5, 6, and 7.