<commit_before>.. index::
   single: Orders

Orders
======

*Order* model is one of the most important in Sylius, it represents the order placed via your store! It has a very consistent and clear API, which allows you to easily manipulate and process orders.

Customer Reference
------------------

*Order* always holds a reference to specific *User*, which is available through ``getUser()`` method:

.. code-block:: php

    echo $order->getUser()->getEmail(); // <EMAIL>

When creating order programatically, you can define the user yourself:

.. code-block:: php

    $order = $this->get('sylius.repository.order')->createNew();
    $john = $this->get('sylius.repository.user')->find(3);

    $order->setUser($john);

Billing and Shipping Address
----------------------------

By default, every order has its own *billing* and *shipping* address, which are heavily used through whole process. Both of them are represented by *Address* model.

.. code-block:: php

    $shippingAddress = $order->getShippingAddress();

    echo 'Shipped to: '.$shippingAddress->getCountry();

Order Contents
--------------

*Order* holds a collection of  *OrderItem* instances.

**OrderItem** model has the attributes listed below:

+------------------+-----------------------------+
| Attribute        | Description                 |
+==================+=============================+
| id               | Unique id of the item       |
+------------------+-----------------------------+
| order            | Reference to an Order       |<commit_msg>Update Order documentation according to Guest Checkout<commit_after>.. index::
   single: Orders

Orders
======

*Order* model is one of the most important in Sylius, it represents the order placed via your store! It has a very consistent and clear API, which allows you to easily manipulate and process orders.

Customer Reference
------------------

*Order* holds a reference to specific *User*, which is available through ``getUser()`` method:

.. code-block:: php

    echo $order->getUser()->getEmail(); // <EMAIL>

When creating order programatically, you can define the user yourself:

.. code-block:: php

    $order = $this->get('sylius.repository.order')->createNew();
    $john = $this->get('sylius.repository.user')->find(3);

    $order->setUser($john);

*Order* may not have reference to *User* in case when *Order* was created by guest.

Billing and Shipping Address
----------------------------

By default, every order has its own *billing* and *shipping* address, which are heavily used through whole process. Both of them are represented by *Address* model.

.. code-block:: php

    $shippingAddress = $order->getShippingAddress();

    echo 'Shipped to: '.$shippingAddress->getCountry();

Order Contents
--------------

*Order* holds a collection of  *OrderItem* instances.

**OrderItem** model has the attributes listed below:

+------------------+-----------------------------+
| Attribute        | Description                 |
+==================+=============================+
| id               | Unique id of the item       |
+------------------+-----------------------------+
| order            | Reference to an Order       |
{'fraction_non_alphanumeric': 0.2272015042306487, 'fraction_numerical': 0.0006267627702914447, 'mean_word_length': 2.392136025504782, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2305215', 'n_tokens_mistral': 808, 'n_tokens_neox': 765, 'n_words': 310}