+++ +++
The Order model represents an order placed with your shop. Orders consist of OrderItems, which are the Products that are attached to the order. An order can have a Customer attached to it, but this is not required. And order must have a DeliveryMode attached to it to select the method of shipment. The payment attributes are provided for the customer to indicate to the shop when and how payment was made so the shop can verify payment. If payment was received through an online payment system, the shop may store that information in the order if they want.
Model attributes can be accessed two ways:
$order->mc_number
]
$order->getMcNumber()
]
Model setters always return the object itself, which allows you to chain setter calls:
$order->setId(27) ->setName('Mr. Buyer') ->setOrderNumber('Shop-00081') ->setAddress('49 Buyer Lane') ->setPostcode('10110');
setCustomer()
with a Customer object.
setDeliveryMode()
with a DeliveryMode object.
Files that are attached to this order.
Method getAttachments() returns an array of the order's attachments when an order is retrieved from the API. Each element of the array is an associative array containing a 'name' and a 'url'. The url can be used to retrieve the attachment using a standard HTTP request.
Method attachFile() is used to attach a new file to an order when creating or updating an order. 'name' is the attachment name used to refer to the attachment during processing of the order. The name must be one that MyCloud will understand, so be sure it is one that is agreed upon with the MyCloud staff. 'filename' is any name you wish to give the file, and is typically the attachment's local file name. 'filetype' indicates what type of file the attachment is, and should typically be a stadard MIME type such as 'image/jpeg' or 'application/pdf'. 'filepath' is the pathname to the local file on the computer that is attaching the file to the order. The filepath must be sufficient for the code to locate the file during processing, so a full path is recommended. Returns the Order object.
A shop customer that is attached to the order.
Method getCustomer() returns the Customer that is attached to the order, or NULL if no customer is attached to the order. The Customer object must be obtained from the API, not created by the client's code.
Method setCustomer() is used to attach a new customer to an order when creating or updating an order. Returns the Order object.
The delivery mode to be used to ship the order.
Method getDeliveryMode() returns the DeliveryMode that is attached to the order, or NULL if no delivery mode is defined for the order. The DeliveryMode object must be obtained from the API, not created by the client's code.
Method setDeliveryMode() is used to define the delivery mode for the order when creating or updating an order. Returns the Order object.
The order items are the products that are being purchased with this order. An OrderItem points to a Product and defines the number of that product being purchased (quantity) and the price being paid for that product (price). When you retrieve an order from the API, the order's items will be attached to the Order object for you. When you are creating a new order, or updating an existing order, you will provide the OrderItems to be added to the order.
Order defines several methods that allow you to attach order items to your order when you are creating or updating an order:
Method addOrderItem() allows you to add an order item using an OrderItem object that you create.
Method addProduct() allows you to create a new order item using a Product object that you have retrieved from the API. It will create the new OrderItem using the Product object's id. You can get this Product object using the API, or you can create a new Product object locally, in which case you only need to provide the id when creating the object.
Method addProductBytId() is the same as addProduct(), but you only need the id of the product. This allows you to keep a list of product ids on your system, so you do not need to retrieve them from the API each time you want to create a new order.
Method addProductBySKU() is the same as addProduct(), but you only need the MyCloud SKU of the product. This allows you to keep a list of product MyCloud SKUs on your system, so you do not need to retrieve them from the API each time you want to create a new order.
Method addProductByShopSKU() is the same as addProduct(), but you only need the Shop SKU of the product. The Shop SKU is the SKU number that your shop has assigned to the product. This allows you to keep a list of product SKUs on your system, so you do not need to retrieve them from the API each time you want to create a new order.