sonnenglas / amazon-mws-laravel

A library to connect to Amazon's MWS web services in an object oriented manner
Apache License 2.0
64 stars 73 forks source link

list orders #27

Open aryanj723 opened 5 years ago

aryanj723 commented 5 years ago

How to get full info of any order in orderlist, not just these 5 parameters,, I would also like to have info such as state, fulfilment type, and others

Dhavalptel commented 5 years ago

@aryanj723 You can get a list of orders using this

 try {
            $amz = new AmazonOrderList("mystore"); //store name matches the array key in the config file
            $amz->setLimits('Created', "- 30 days"); //accepts either specific timestamps or relative times
            $amz->setFulfillmentChannelFilter("AFN"); //no Amazon-fulfilled orders
            $amz->setOrderStatusFilter(
                array("Unshipped", "PartiallyShipped", "Canceled", "Unfulfillable")
            ); //no shipped or pending orders
            $amz->setUseToken(); //tells the object to automatically use tokens right away
            $amz->fetchOrders(); //this is what actually sends the request
            return $amz->getList();
        } catch (Exception $ex) {
            echo 'There was a problem with the Amazon library. Error: '.$ex->getMessage();
        }

And then from that response you can use amazon order id and fetch individual order.

        $order = new AmazonOrderItemList("mystore");
        $order->setOrderId($orderId);
        $order->fetchItems();
        return $order->getItems();

Hope that helps Thanks