How to Add custom attributes to the products?

Solved
DeepAmin
New Member
3 0 0

I want to add some custom attributes to the product. 

I have product detail page in which we are collecting custom attributes and one checkout button.

I have tried with some solutions like adding custom attributes as below:

var input = Storefront.CheckoutCreateInput()
            .setLineItemsInput(Input.value(Arrays.asList(
                    Storefront.CheckoutLineItemInput(quantity, ID( variantId ))
                        .setCustomAttributes(attributes)
            )))

but I am not able to add attributes with above solution. 
I am using latest shopify mobile buy SDK.

 

Please guide us, How to add custom attributes to the products?

Thanks

0 Likes
KarlOffenberger
Shopify Partner
1867 182 777

This is an accepted solution.

Hi,

 

Any chance you could intercept the actual GraphQL just before the request is being made?

 

I don't have the Mobile Buy SDK for Android setup to check what's going on, but using regular Storefront API I see no issues adding custom attributes

 

mutation {
  checkoutCreate(input: {
    lineItems: [
      { 
        variantId: "<VARIANT_ID>",
        quantity: 1
      }
    ],
    customAttributes: [
      {
        key: "foo",
        value: "bar"
      }
    ]
  }) {
    checkout {
       id
       webUrl
    }
  }
}

Cheers!

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
DeepAmin
New Member
3 0 0

Hi, 

Your above given solution is worked for me. 

but now I am facing another problem and I need your help into this.

I want to add tags field while creating checkout. I also tried by adding in custom Attributes but it is not working as per my expectation.

So can you please help me, how to add tags field in Storefront.createCheckout query calling?

0 Likes
AvidBrio
Shopify Expert
125 6 12

@KarlOffenberger 

it's possible to add a line-item or a note with the product buy now button js code SDK? 

If you find our comment helpful, hit the like button and accept it as a solution.
Want us to implement custom changes in your store? Contact us
Email me directly - jim@avidbrio.com
0 Likes