skip to Main Content

Hi i am using below mentioned code for pulling order conformation. But i can’t get Order ID and order details from this Query. Not able to get order id and order details even order confirmed.
Currently i am using shopify mobilebuysdk:buy3:3.1.1

graphClient!!.queryGraph(query).enqueue(
    object : GraphCall.Callback<Storefront.QueryRoot> {
        override fun onResponse(@NonNull response: GraphResponse<Storefront.QueryRoot>) {

            if (response.data()!!.getNode() as Storefront.Checkout != null) {
                val checkout = response.data()!!.getNode() as Storefront.Checkout
                println("CheckOut : " + checkout)

                if (checkout != null) {

                    if (checkout.getOrder() != null) {
                        if (checkout.getOrder().getId().toString() != null) {
                            val orderId = checkout.getOrder().getId().toString()
                            println("Order ID : " + orderId)
                        }
                    }

                }


            }


        }

        override fun onFailure(@NonNull error: GraphError) {}
    }, null,
    RetryHandler.exponentialBackoff(1, TimeUnit.MILLISECONDS, 1.2f)
            .whenResponse<Storefront.QueryRoot> { response ->
                (response.data()?.getNode() as Storefront.Checkout).getOrder() == null
            }
            .maxCount(10)
            .build())

2

Answers


  1. Chosen as BEST ANSWER
    val checkoutId = ID(tinyDB!!.getString("New_checkoutID"))
        val query = Storefront.query({ rootQuery ->
            rootQuery
                    .node(checkoutId, { nodeQuery ->
                        nodeQuery
                                .onCheckout({ checkoutQuery ->
                                    checkoutQuery
                                            .order({ orderQuery ->
                                                orderQuery
                                                        .orderNumber()
                                                        .totalPrice()
                                                        .processedAt()
                                            }
    
                                            )
                                }
                                )
                    }
                    )
        }
        )    
    
    graphClient!!.queryGraph(query).enqueue(
                object : GraphCall.Callback<Storefront.QueryRoot> {
                    override fun onResponse(@NonNull response: GraphResponse<Storefront.QueryRoot>) {
                        val checkout = response.data()!!.getNode() as Storefront.Checkout
                        val orderId = checkout.getOrder().getId().toString()
                    }
    
                    override fun onFailure(@NonNull error: GraphError) {}
                }, null,
                RetryHandler.exponentialBackoff(1, TimeUnit.MILLISECONDS, 1.2f)
                        .whenResponse<Storefront.QueryRoot>(
                                { response -> (response.data().getNode() as Storefront.Checkout).getOrder() == null }
                        )
                        .maxCount(10)
                        .build()
        )
    

  2. Have a look at this answer,
    Shopify Web Checkout Issue

    First thing is to remove HttpCachePolicy from the QraphQL setup. After it try to provide the Network_Only to order status api.

    And your issue will be gone.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search