Overview
  • Namespace
  • Class

Namespaces

  • MailChimp
    • AuthorizedApps
    • Automations
    • Batches
    • CampaignFolders
    • Campaigns
    • Conversations
    • Ecommerce
    • FileManager
    • Lists
    • Reports
    • TemplateFolders
    • Templates

Classes

  • MailChimp\AuthorizedApps\AuthorizedApps
  • MailChimp\Automations\Automations
  • MailChimp\Batches\Batches
  • MailChimp\CampaignFolders\CampaignFolders
  • MailChimp\Campaigns\Campaigns
  • MailChimp\Campaigns\Content
  • MailChimp\Campaigns\Feedback
  • MailChimp\Conversations\Conversations
  • MailChimp\Ecommerce\Carts
  • MailChimp\Ecommerce\Customers
  • MailChimp\Ecommerce\Ecommerce
  • MailChimp\Ecommerce\Orders
  • MailChimp\Ecommerce\Products
  • MailChimp\FileManager\Files
  • MailChimp\FileManager\Folders
  • MailChimp\Lists\Interests
  • MailChimp\Lists\Lists
  • MailChimp\Lists\Members
  • MailChimp\Lists\MergeFields
  • MailChimp\Lists\Segments
  • MailChimp\Lists\SignupForms
  • MailChimp\Lists\Webhooks
  • MailChimp\MailChimp
  • MailChimp\Reports\Reports
  • MailChimp\TemplateFolders\TemplateFolders
  • MailChimp\Templates\Templates
  1 <?php
  2 namespace MailChimp\Ecommerce;
  3 
  4 class Orders extends Ecommerce
  5 {
  6 
  7     /**
  8      * TODO: comment requirements
  9      */
 10 
 11      /**
 12       * Get information about a store’s orders.
 13       *
 14       * array["fields"]              array       list of strings of response fields to return
 15       * array["exclude_fields"]      array       list of strings of response fields to exclude (not to be used with "fields")
 16       * array["count"]               int         number of records to return
 17       * array["offset"]              int         number of records from a collection to skip.
 18       * array["customer_id"]         string      Restrict results to orders made by a specific customer.
 19       *
 20       * @param string $store_id
 21       * @param array $query (See Above) OPTIONAL associative array of query parameters.
 22       * @return object
 23       */
 24     public function getOrders($store_id, array $query = [])
 25     {
 26         return self::execute("GET", "ecommerce/stores/{$store_id}/orders", $query);
 27     }
 28 
 29     /**
 30      * Get information about a specific order.
 31      *
 32      * array["fields"]              array       list of strings of response fields to return
 33      * array["exclude_fields"]      array       list of strings of response fields to exclude (not to be used with "fields")
 34      */
 35     public function getOrder($store_id, $order_id, array $query = [])
 36     {
 37         return self::execute("GET", "ecommerce/stores/{$store_id}/orders/{$order_id}", $query);
 38     }
 39 
 40     /**
 41      * Add a new order to a store.
 42      *
 43      * @param string $store_id
 44      * @param string $order_id
 45      * @param string $currency_code
 46      * @param number $order_total
 47      * @param array $customer See addCustomer method in Customer class
 48      * @param array $lines See addOrderLine method below
 49      * @param array $optional_settings
 50      * @return object
 51      */
 52     public function addOrder($store_id, $order_id, $currency_code, $order_total, array $customer = [], array $lines = [], array $optional_settings = null)
 53     {
 54         $optional_fields = ["campaign_id", "financial_status", "tax_total", "shipping_total", "tracking_code", "processed_at_foreign", "updated_at_foreign", "cancelled_at_foreign", "shipping_address", "billing_address"];
 55         $data = [
 56             "id" => $order_id,
 57             "customer" => $customer,
 58             "currency_code" => $currency_code,
 59             "order_total" => $order_total,
 60             "lines" => $lines
 61         ];
 62 
 63         // If the optional fields are passed, process them against the list of optional fields.
 64         if (isset($optional_settings)) {
 65             $data = array_merge($data, self::optionalFields($optional_fields, $optional_settings));
 66         }
 67         return self::execute("POST", "ecommerce/stores/{$store_id}/orders/", $data);
 68     }
 69 
 70     /**
 71      * Update an order
 72      *
 73      * @param string $store_id
 74      * @param string $order_id
 75      * @param array $data
 76      * @return object
 77      */
 78     public function updateOrder($store_id, $order_id, array $data = [])
 79     {
 80         return self::execute("PATCH", "ecommerce/stores/{$store_id}/orders/{$order_id}", $data);
 81     }
 82 
 83     /**
 84      * Get information about a order’s line items
 85      *
 86      * array["fields"]              array       list of strings of response fields to return
 87      * array["exclude_fields"]      array       list of strings of response fields to exclude (not to be used with "fields")
 88      * array["count"]               int         number of records to return
 89      * array["offset"]              int         number of records from a collection to skip.
 90      *
 91      * @param string $store_id
 92      * @param string $order_id
 93      * @param array $query (See Above) OPTIONAL associative array of query parameters.
 94      * @return object
 95      */
 96     public function getOrderLines($store_id, $order_id, array $query = [])
 97     {
 98         return self::execute("GET", "ecommerce/stores/{$store_id}/orders/{$order_id}/lines", $query);
 99     }
100 
101     /**
102      * Get information about a specific order line item.
103      *
104      * array["fields"]              array       list of strings of response fields to return
105      * array["exclude_fields"]      array       list of strings of response fields to exclude (not to be used with "fields")
106      *
107      * @param string $store_id
108      * @param string $order_id
109      * @param array $query (See Above) OPTIONAL associative array of query parameters.
110      * @return object
111      */
112     public function getOrderLine($store_id, $order_id, $line_id, array $query = [])
113     {
114         return self::execute("GET", "ecommerce/stores/{$store_id}/orders/{$order_id}/lines/{$line_id}", $query);
115     }
116 
117     /**
118      * Add a new line item to an existing order
119      *
120      * @param string $store_id
121      * @param string $order_id
122      * @param string $line_id
123      * @param string $product_id
124      * @param string $product_variant_id
125      * @param int $quantity
126      * @param number price
127      * @return object
128      */
129     public function addOrderLine($store_id, $order_id, $line_id, $product_id, $product_variant_id, $quantity, $price)
130     {
131         $data = [
132             "id" => $line_id,
133             "product_id" => $product_id,
134             "product_variant_id" => $product_variant_id,
135             "quantity" => $quantity,
136             "price" => $price
137         ];
138         return self::execute("POST", "ecommerce/stores/{$store_id}/orders/{$order_id}/lines/", $data);
139     }
140     /**
141      * Update a line item to an existing order
142      *
143      * @param string $store_id
144      * @param string $order_id
145      * @param string $line_id
146      * @param array $data
147      * @return object
148      */
149     public function updateOrderLine($store_id, $order_id, $line_id, array $data = [])
150     {
151         return self::execute("PATCH", "ecommerce/stores/{$store_id}/orders/{$order_id}/lines/{$line_id}", $data);
152     }
153 
154     /**
155      * Delete a line item to an existing order
156      *
157      * @param string $store_id
158      * @param string $order_id
159      * @param string $line_id
160      */
161     public function deleteOrderLine($store_id, $order_id, $line_id)
162     {
163         return self::execute("DELETE", "ecommerce/stores/{$store_id}/orders/{$order_id}/lines/{$line_id}");
164     }
165 
166     /**
167      * Delete an existing order
168      *
169      * @param string $store_id
170      * @param string $order_id
171      */
172     public function deleteOrder($store_id, $order_id)
173     {
174         return self::execute("DELETE", "ecommerce/stores/{$store_id}/orders/{$order_id}");
175     }
176 
177 }
178 
API documentation generated by ApiGen