Shopfront hydrogen custom cart_attribute POST to shopify backend.

LuLue
Shopify Partner
4 0 0

Hi, I'm trying to create custom cart_attribute, but I'm not able to find that cart_attribute that I POST with graphQL in shopify backend. Am i missing anything? 



Here's what I did

<fetcher.Form action="/cart" method="post">
      <input type="hidden" name="cartAction" value={CartAction.ADD_TO_CART} />
      <input
        type="hidden"
        name="lines"
        id="lines"
        value={JSON.stringify(lines)}
      />
      <input
        type="hidden"
        name="attributes"
        id="attributes"
        value={JSON.stringify(props?.attributes)}
      />
      <input type="hidden" name="analytics" value={JSON.stringify(analytics)} />
      <Button
        as="button"
        type="submit"
        width={width}
        variant={variant}
        className={className}
        disabled={disabled ?? fetcherIsNotIdle}
        {...props}
      >
        {children}
      </Button>
    </fetcher.Form>

 

And also I wired that into cart action

  if (!cartId) {
        result = await cartCreate({
          input: countryCode
            ? {lines, buyerIdentity: {countryCode}, attributes}
            : {lines, attributes},
          storefront,
        });
      } else {
        result = await cartAdd({
          cartId,
          lines,
          storefront,
        });
      }

 

I'm sure the custom property is wired in this cart, so the question is how do i checkout this custom data? 

Reply 1 (1)
LuLue
Shopify Partner
4 0 0

I just solved the issue. I need to put that in lines array