How to Store and Retrieve NIF/CIF from Checkout for Invoicing in Shopify (Spain Compliance)

Hi, I’m implementing a Shopify store and I need technical help managing VAT ID (NIF/CIF) in the checkout to comply with Spanish invoicing regulations.

I’ve added a mandatory field in the checkout where customers enter their NIF/CIF. Shopify Support has informed me of the following:

  • The NIF/CIF value is not automatically stored in the customer profile.

  • Custom checkout fields may be saved in:

    • order custom attributes

    • order or customer metafields

    • order note attributes

They confirmed that I can retrieve this value from the Order object after the payment is completed via customAttributes. However, there is no clear documentation explaining:

  1. How to ensure this value (NIF/CIF) is reliably stored

  2. How to persist this value as a customer metafield for future invoices

  3. How to work with the Admin GraphQL API to:

    • retrieve NIF/CIF from the order

    • store it in the customer’s metafield

    • access it later when generating invoices

:red_question_mark: What I need to know

  1. What is the correct and documented way to access the checkout NIF/CIF attribute from the Order object using GraphQL?

  2. Does anyone have a working GraphQL mutation example that saves this value into a customer metafield?
    Something similar to:


mutation customerUpdate($input: CustomerInput!) {
  customerUpdate(input: $input) {
    customer {
      id
      metafields(first: 10) {
        edges {
          node {
            namespace
            key
            value
          }
        }
      }
    }
  }
}

  1. What is the recommended best practice to automate this process, ensuring no manual steps are required?

:chequered_flag: End goal

To issue legally valid invoices in Spain, I must include the customer’s NIF/CIF. I need to guarantee that this value:

  • is captured correctly at checkout :check_mark:

  • is stored in a persistent way :check_mark:

  • is accessible when generating invoices :check_mark:

If anyone has implemented this, or has official documentation, examples, or guidance, it would be extremely helpful.

Thank you!

Hola, estoy implementando una tienda en Shopify y necesito ayuda técnica con la gestión del NIF/CIF en el checkout para cumplir con la normativa española de facturación.

Actualmente, he añadido un campo obligatorio en el checkout donde el cliente introduce su NIF o CIF. El soporte de Shopify me ha informado lo siguiente:

  • El NIF/CIF no se almacena automáticamente como parte del perfil del cliente.

  • Los campos personalizados del checkout pueden guardarse en:

    • order custom attributes (atributos personalizados del pedido)

    • metafields en el pedido o en el cliente

    • order note attributes

Me han confirmado que puedo recuperar estos valores desde el objeto Order una vez completado el pago, a través de customAttributes. Sin embargo, no existe documentación clara para:

  1. Cómo asegurar que este dato (NIF/CIF) siempre se guarde de forma persistente

  2. Cómo mover ese dato al metafield del cliente de forma automática

  3. Cómo usar la Admin GraphQL API para:

    • recuperar el NIF/CIF del pedido

    • guardarlo en el metafield del cliente

    • acceder a dicho metafield al generar una factura

Lo que necesito saber

  1. ¿Cuál es la forma correcta y documentada de acceder al atributo NIF/CIF del checkout desde el objeto Order usando GraphQL?

  2. ¿Alguien tiene un ejemplo funcional de mutación GraphQL para guardar ese valor en un metafield de cliente?
    Algo como:

mutation customerUpdate($input: CustomerInput!) {
  customerUpdate(input: $input) {
    customer {
      id
      metafields(first: 10) {
        edges {
          node {
            namespace
            key
            value
          }
        }
      }
    }
  }
}

  1. ¿Cuál sería la mejor práctica para que este proceso sea automático y no requiera intervención manual?

Objetivo final

Tengo que generar facturas legales en España, y para ello es obligatorio incluir el NIF/CIF del cliente. Necesito garantizar que este valor:

  • se capture correctamente en el checkout :check_mark:

  • se guarde de forma persistente :check_mark:

  • esté accesible al generar la factura en mi flujo de trabajo :check_mark:

Si alguien ha implementado esto o tiene recursos, ejemplos o documentación oficial, cualquier orientación sería de gran ayuda.

¡Muchas gracias!