Shopify / mobile-buy-sdk-android

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using their credit card.
MIT License
214 stars 137 forks source link

How to send Monogram and Gift wrap option while checkout in Android mobile app. #618

Closed Bhargavasrinivas closed 4 years ago

Bhargavasrinivas commented 4 years ago

Hii Everyone.

I am developing an android app using Android buy sdk , where we are selling perfumes , but here i had given them an option of Gift wrapping and monogram , is there any api support to send this gift wrapping and monogram (like letters to print on the bottle )as parameter while checkout. i am using web-checkout to full fill the orders.

vixdug commented 4 years ago

Hi @Bhargavasrinivas You will want to utilize custom attributes. Here is an example:

/**
        * A list of extra information that is added to the checkout.
        */

        public List<Attribute> getCustomAttributes() {
            return (List<Attribute>) get("customAttributes");
        }

        public Checkout setCustomAttributes(List<Attribute> arg) {
            optimisticData.put(getKey("customAttributes"), arg);
            return this;
        }

You can find more information in storefront.java. You can also read through the storefront API documentation here

Bhargavasrinivas commented 4 years ago

Hii Vixdug, Thanks for your help , but i bit confused that how to send custom attributes as as parameter fo check out api , below i pasted my code snippet can u know how to send monogram and gift wrap option for this code

        var quantity :Int! = 0

        for index  in 0..<CartClsArray.count {

            quantity = Int(CartClsArray[index].Quantity)

            var productId = CartClsArray[index].ProductVarinatId

            dataList.append(Storefront.CheckoutLineItemInput(quantity: Int32(CartClsArray[index].Quantity)!,variantId: GraphQL.ID(rawValue: productId)))

        }

        let checkoutInput = Storefront.CheckoutCreateInput.create(
            lineItems: .value(dataList)

        )

        let mutation = Storefront.buildMutation { $0
            .checkoutCreate(input:checkoutInput) { $0
                .checkout { $0
                    .id()
                    .webUrl()

                }
                .userErrors { $0
                    .field()
                    .message()
                }
            }
        } 

for example like some customer as purchased a perfume bottle and he wants print some birthday wishes on that bottle (Happy birthday) and he wants us to gift wrap that and i had given option him for both , here how to send both parameter here for checkout