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 Carts extends Ecommerce
  5 {
  6 
  7     /**
  8      * Get information about a store’s carts.
  9      *
 10      * array["fields"]              array       list of strings of response fields to return
 11      * array["exclude_fields"]      array       list of strings of response fields to exclude (not to be used with "fields")
 12      * array["count"]               int         number of records to return
 13      * array["offset"]              int         number of records from a collection to skip.
 14      *
 15      * @param string $store_id
 16      * @param array $query (See Above) OPTIONAL associative array of query parameters.
 17      * @return object
 18      */
 19     public function getCarts($store_id, array $query = [])
 20     {
 21         return self::execute("GET", "ecommerce/stores/{$store_id}/carts", $query);
 22     }
 23 
 24     /**
 25      * Get information about a specific cart.
 26      *
 27      * array["fields"]              array       list of strings of response fields to return
 28      * array["exclude_fields"]      array       list of strings of response fields to exclude (not to be used with "fields")
 29      */
 30     public function getCart($store_id, $cart_id, array $query = [])
 31     {
 32         return self::execute("GET", "ecommerce/stores/{$store_id}/carts/{$cart_id}", $query);
 33     }
 34 
 35     /**
 36     * Add a new cart to a store.
 37     *
 38     * @param string $store_id
 39     * @param string $cart_id
 40     * @param string $currency_code
 41     * @param number $cart_total
 42     * @param array $customer See addCustomer method in Customer class
 43     * @param array $lines See addOrderLine method below
 44     * @param array $optional_settings
 45     * @return object
 46     */
 47     public function addCart($store_id, $cart_id, $currency_code, $cart_total, array $customer = [], array $lines = [], array $optional_settings = null)
 48     {
 49         $optional_fields = ["campaign_id", "checkout_url", "tax_total"];
 50         $data = [
 51             "id" => $cart_id,
 52             "customer" => $customer,
 53             "currency_code" => $currency_code,
 54             "order_total" => $cart_total,
 55             "lines" => $lines
 56         ];
 57         // If the optional fields are passed, process them against the list of optional fields.
 58         if (isset($optional_settings)) {
 59             $data = array_merge($data, self::optionalFields($optional_fields, $optional_settings));
 60         }
 61         return self::execute("POST", "ecommerce/stores/{$store_id}/carts", $data);
 62     }
 63 
 64     /**
 65      * Update a cart
 66      *
 67      * @param string $store_id
 68      * @param string $cart+id
 69      * @param array $data
 70      * @return object
 71      */
 72 
 73     public function updateCart($store_id, $cart_id, array $data = [])
 74     {
 75         return self::excecute("PATCH", "ecommerce/stores/{$store_id}/carts/{$cart_id}", $data);
 76     }
 77 
 78     /**
 79      * Get information about a cart’s line items
 80      *
 81      * array["fields"]              array       list of strings of response fields to return
 82      * array["exclude_fields"]      array       list of strings of response fields to exclude (not to be used with "fields")
 83      * array["count"]               int         number of records to return
 84      * array["offset"]              int         number of records from a collection to skip.
 85      *
 86      * @param string $store_id
 87      * @param string $cart_id
 88      * @param array $query (See Above) OPTIONAL associative array of query parameters.
 89      * @return object
 90      */
 91     public function getCartLines($store_id, $cart_id, array $query = [])
 92     {
 93         return self::execute("GET", "ecommerce/stores/{$store_id}/carts/{$cart_id}/lines", $query);
 94     }
 95 
 96     /**
 97      * Get information about a specific cart line item.
 98      *
 99      * array["fields"]              array       list of strings of response fields to return
100      * array["exclude_fields"]      array       list of strings of response fields to exclude (not to be used with "fields")
101      *
102      * @param string $store_id
103      * @param string $cart_id
104      * @param array $query (See Above) OPTIONAL associative array of query parameters.
105      * @return object
106      */
107     public function getCartLine($store_id, $cart_id, $line_id, array $query = [])
108     {
109         return self::execute("GET", "ecommerce/stores/{$store_id}/carts/{$cart_id}/lines/{$line_id}", $query);
110     }
111 
112     /**
113      * Add a new line item to an existing cart
114      *
115      * @param string $store_id
116      * @param string $cart_id
117      * @param string $line_id
118      * @param string $product_id
119      * @param string $product_variant_id
120      * @param int $quantity
121      * @param number price
122      * @return object
123      */
124     public function addCartLine($store_id, $cart_id, $line_id, $product_id, $product_variant_id, $quantity, $price)
125     {
126         $data = [
127             "id" => $line_id,
128             "product_id" => $product_id,
129             "product_variant_id" => $product_variant_id,
130             "quantity" => $quantity,
131             "price" => $price
132         ];
133         return self::execute("POST", "ecommerce/stores/{$store_id}/carts/{$cart_id}/lines/", $data);
134     }
135     /**
136      * Update a line item to an existing cart
137      *
138      * @param string $store_id
139      * @param string $cart_id
140      * @param string $line_id
141      * @param array $data
142      * @return object
143      */
144     public function updateCartLine($store_id, $cart_id, $line_id, array $data = [])
145     {
146         return self::execute("PATCH", "ecommerce/stores/{$store_id}/carts/{$cart_id}/lines/{$line_id}", $data);
147     }
148 
149     /**
150      * Delete a line item to an existing cart
151      *
152      * @param string $store_id
153      * @param string $cart_id
154      * @param string $line_id
155      */
156     public function deleteCartLine($store_id, $cart_id, $line_id)
157     {
158         return self::execute("DELETE", "ecommerce/stores/{$store_id}/carts/{$cart_id}/lines/{$line_id}");
159     }
160 
161     /**
162      * Delete a cart
163      *
164      * @param string $store_id
165      * @param string $cart_id
166      */
167     public function deleteCart($store_id, $cart_id)
168     {
169         return self::execute("DELETE", "ecommerce/stores/{$store_id}/carts/{$cart_id}");
170     }
171 
172 
173 }
174 
API documentation generated by ApiGen