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
216 stars 136 forks source link

Customer Orders returing null values #555

Closed Bhargavasrinivas closed 5 years ago

Bhargavasrinivas commented 6 years ago

Hi, I am new to Shopify and I am developing an android app using Shopify storefront APIs, I integrated the customer order api but the response is always null. Below is my code

        Storefront.QueryRootQuery query = Storefront.query(root -> root
                .customer(Util.accessToken, customer -> customer
                        .orders(arg -> arg.first(10), connection -> connection
                                .edges(edge -> edge
                                        .node(node -> node
                                                .orderNumber()
                                                .totalPrice()
                                                .subtotalPrice()
                                                .statusUrl()

                                        )
                                )
                        )
                )
        );

        QueryGraphCall call = graphClient.queryGraph(query);

        call.enqueue(new GraphCall.Callback<Storefront.QueryRoot>() {
            @Override
            public void onResponse(@NonNull GraphResponse<Storefront.QueryRoot> response) {
                progressDialog.dismiss();
                Storefront.OrderConnection res = response.data().getCustomer().getOrders();
            }
            @Override
            public void onFailure(@NonNull GraphError error) {
                progressDialog.dismiss();
                Toast.makeText(getApplicationContext(), " Error" + error.getMessage(), Toast.LENGTH_SHORT).show();

            }
        });

Thanks in Advance.

GujaratiMonali commented 6 years ago

please try this code..

Storefront.QueryRootQuery query = Storefront.query(root -> root
                .customer(accessToken, customer -> customer 
                        .orders(arg -> arg.first(10), connection -> connection
                                .edges(edge -> edge
                                        .node(node -> node
                                                .orderNumber()
                                                .totalPrice()
                                                .email()
                                                .phone()
                                                .totalShippingPrice()
                                                .totalTax()
                                                .totalRefunded()
                                                .currencyCode()
                                                .customerUrl()
                                                .statusUrl()
                                                .processedAt()
                                                .customerLocale()
                                                .subtotalPrice()

                                        )
                                )
                        )
                )
        );
    QueryGraphCall call = graphClient.queryGraph(query);
        call.enqueue(new GraphCall.Callback<Storefront.QueryRoot>() {

            @Override
            public void onResponse(@NonNull GraphResponse<Storefront.QueryRoot> response) {

                    for (int i = 0; i < response.data().getCustomer().getOrders().getEdges().size(); i++) {

                        Log.e("order", "order number.." + response.data().getCustomer().getOrders().getEdges().get(i).getNode().getOrderNumber());
                        Log.e("order", "order id.." + response.data().getCustomer().getOrders().getEdges().get(i).getNode().getId());
                        Log.e("order", "processedA.." + response.data().getCustomer().getOrders().getEdges().get(i).getNode().getProcessedAt());
                        Log.e("order", "statusUrl.." + response.data().getCustomer().getOrders().getEdges().get(i).getNode().getStatusUrl());
                        Log.e("order", "currencycode.." + response.data().getCustomer().getOrders().getEdges().get(i).getNode().getCurrencyCode());
                        Log.e("order", "customerUrl.." + response.data().getCustomer().getOrders().getEdges().get(i).getNode().getCustomerUrl());
                        Log.e("order", "totalTax.." + response.data().getCustomer().getOrders().getEdges().get(i).getNode().getTotalTax());
                        Log.e("order", "totalShippingPrice.." + response.data().getCustomer().getOrders().getEdges().get(i).getNode().getTotalShippingPrice());
                        Log.e("order", "customerLocale.." + response.data().getCustomer().getOrders().getEdges().get(i).getNode().getCustomerLocale());
                        Log.e("order", "subtotalPrice.." + response.data().getCustomer().getOrders().getEdges().get(i).getNode().getSubtotalPrice());
                    }
            }
            @Override
            public void onFailure(@NonNull GraphError error) {
                Log.e("TAG", "Failed to execute query", error);
            }
        });

any query than please ask me....