question

raman22500 avatar image
raman22500 asked raman22500 commented

Not able to listen from OrderV3Connector.OnOrderUpdateListener2, while order is created, updated, discount added, Item added

we need to trigger an event while order is updated, discount added in order and item added in order.

I am using below code :

public class OrderUpdated extends Service {
    String TAG = String.valueOf(MyApplication.getAppContext());

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        new OrderV3Connector.OnOrderUpdateListener2() {
            @Override
            public void onOrderUpdated(String orderId, boolean selfChange) {
            }

            @Override
            public void onOrderCreated(String orderId) {
            }

            @Override
            public void onOrderDeleted(String orderId) {
            }

            @Override
            public void onOrderDiscountAdded(String orderId, String discountId) {
            }

            @Override
            public void onOrderDiscountsDeleted(String orderId, List<String> discountIds) {
            }

            @Override
            public void onLineItemsAdded(String orderId, List<String> lineItemIds) {
            }

            @Override
            public void onLineItemsUpdated(String orderId, List<String> lineItemIds) {
            }

            @Override
            public void onLineItemsDeleted(String orderId, List<String> lineItemIds) {
            }

            @Override
            public void onLineItemModificationsAdded(String orderId, List<String> lineItemIds, List<String> modificationIds) {
            }

            @Override
            public void onLineItemDiscountsAdded(String orderId, List<String> lineItemIds, List<String> discountIds) {
            }

            @Override
            public void onLineItemExchanged(String orderId, String oldLineItemId, String newLineItemId) {
            }

            public void onPaymentProcessed(String orderId, String paymentId) {
            }

            @Override
            public void onRefundProcessed(String orderId, String refundId) {
            }

            @Override
            public void onCreditProcessed(String orderId, String creditId) {
            }
        };
        return super.onStartCommand(intent, flags, startId);
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Toast.makeText(MyApplication.getAppContext(), "Service Start", Toast.LENGTH_LONG).show();
        Log.i(TAG, "SeviceStart" + "");
        return null;
    }
}

For start the service :

public void startTheService() {
    Intent intent= new Intent(getActivity(), OrderUpdated.class);
    thiscontext.startService(intent);
}

In Manifest :

<service android:name=".global.OrderUpdated"/>

I tried it but unable to receive any event .

Please suggest, Thanks in advance.





Orders
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeffrey Blattman avatar image
Jeffrey Blattman answered raman22500 commented

Where do you register the listener? You need to call #addOnOrderChangedListener somewhere.

Am I missing something?

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

raman22500 avatar image raman22500 commented ·
@Jeffrey Blattman thank you for your reply.I called the #addOnOrderChangedListener like below, but still not gettting any event. 

 OrderV3Connector orderV3Connector = new OrderV3Connector(MyApplication.getAppContext(),mAccount,this );     
         orderV3Connector.addOnOrderChangedListener(new OrderV3Connector.OnOrderUpdateListener2() {          
             @Override                                                                                       
             public void onOrderUpdated(String orderId, boolean selfChange) {                                
                  Log.i(TAG,"onOrderupdated") ;                                                              
             }                                                                                               
                                                                                                             
             @Override                                                                                       
             public void onOrderCreated(String orderId) {                                                    
                  Log.i(TAG,"onOrderCreated") ;                                                              
             }                                                                                               
                                                                                                             
             @Override                                                                                       
             public void onOrderDeleted(String orderId) {                                                    
                Log.i(TAG,"onOrderDeleted") ;                                                                
             }      
Still am i missing something?                                                                                         
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community