{"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/76749990","id":76749990,"diff_hunk":"@@ -4,49 +4,139 @@\n Shipments\n =========\n \n-...\n+A **Shipment** is a representation of a shipping request for an Order. Sylius supports multiple shipments per one Order.\n+\n+How to create a Shipment programmatically?\n+''''''''''''''''''''''''''''''''''''''''''\n+\n+In order to create a new Shipment - use a factory. Assign a shipping method, and an order - without that data a Shipment would be useless.\n+Finally add your shipment to the repository.\n+\n+.. code-block:: php\n+\n+    $shipment = $this->container->get('sylius.factory.shipment')->createNew();\n+\n+    $shipment->setMethod($shippingMethod);\n+    $shipment->setOrder($order);\n+\n+    $this->container->get('sylius.repository.shipment')->add($shipment);\n \n The Shipment State Machine\n --------------------------\n \n-...\n+A Shipment that is attached to an Order will have its own state machine with such states available:\n+``cart``, ``ready``, ``cancelled``, ``shipped``.\n+\n+The allowed transitions between these states are:\n+\n+.. code-block:: yaml\n+\n+   transitions:\n+        create:\n+            from: [cart]\n+            to: ready\n+        ship:\n+            from: [ready]\n+            to: shipped\n+        cancel:\n+            from: [ready]\n+            to: cancelled\n \n Shipping Methods\n ----------------\n \n-...\n+**ShippingMethod** in Sylius is an entity that represent the way an order can be shipped to a customer.\n \n-Shipping Cost Calculators\n--------------------------\n+How to create a ShippingMethod programmatically?\n+''''''''''''''''''''''''''''''''''''''''''''''''\n+\n+As usually use a factory to create a new ShippingMethod. Give it a ``code``, set a desired shipping calculator, and set a ``zone``.\n+At the end add it to the system using a repository.\n+\n+.. code-block:: php\n+\n+    $shippingMethod = $this->container->get('sylius.factory.shipping_method')->createNew();\n+\n+    $shippingMethod->setCode('DHL');\n+    $shippingMethod->setCalculator(DefaultCalculators::FLAT_RATE);\n+\n+    $zone = $this->container->get('sylius.repository.zone')->findOneByCode('US');\n+    $shippingMethod->setZone($zone);\n \n-...\n+    $this->container->get('sylius.repository.shipping_method')->add($shippingMethod);\n \n-Default Calculators\n--------------------\n+In order to have you shipping method available in checkout add it to a desired channel.\n \n-...\n+.. code-block:: php\n+\n+    $channel->addShippingMethod($shippingMethod);\n \n Shipping Zones\n --------------\n \n-...\n+Sylius has an approach of **Zones** used also for shipping. As in each e-commerce you may be willing to ship only to certain countries for example.\n+therefore while configuring your **ShippingMethods** pay special attention to the zones you are assigning to them.\n+You have to prepare methods for each zone, because the available methods are retrieved for the zone the customer has basing on his address.\n \n-Examples\n---------\n+Shipping Cost Calculators\n+-------------------------\n \n-...\n+The shipping cost calculators are services that are used to calculate the cost for a given shipment.\n \n-Product and ProductVariant Configuration\n-----------------------------------------\n+The `CalculatorInterface <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Component/Shipping/Calculator/CalculatorInterface.php>`_\n+has a method ``calculate()`` that takes object with a configuration and returns *integer* that is the cost of shiping for that subject.\n+It also has a ``getType()`` method that works just like in the forms.\n \n-...\n+To select a proper service we have a one that decides for us\n+- the `DelegatingCalculator <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Component/Shipping/Calculator/DelegatingCalculator.php>`_.\n+Basing on the **ShippingMethod** assigned on the Shipment it will get its calculator type and configuration and calculate the cost properly.\n \n-Final Thoughts\n---------------\n+.. code-block:: php\n+\n+    $this->container->get('sylius.repository.shipment')->add($shipment);","path":"docs/book/shipments.rst","position":111,"original_position":111,"commit_id":"abb83ce83fd95886f2244a64e0857bc9ce49570a","original_commit_id":"abb83ce83fd95886f2244a64e0857bc9ce49570a","user":{"login":"pjedrzejewski","id":614970,"avatar_url":"https://avatars.githubusercontent.com/u/614970?v=3","gravatar_id":"","url":"https://api.github.com/users/pjedrzejewski","html_url":"https://github.com/pjedrzejewski","followers_url":"https://api.github.com/users/pjedrzejewski/followers","following_url":"https://api.github.com/users/pjedrzejewski/following{/other_user}","gists_url":"https://api.github.com/users/pjedrzejewski/gists{/gist_id}","starred_url":"https://api.github.com/users/pjedrzejewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjedrzejewski/subscriptions","organizations_url":"https://api.github.com/users/pjedrzejewski/orgs","repos_url":"https://api.github.com/users/pjedrzejewski/repos","events_url":"https://api.github.com/users/pjedrzejewski/events{/privacy}","received_events_url":"https://api.github.com/users/pjedrzejewski/received_events","type":"User","site_admin":false},"body":"This should be removed.","created_at":"2016-08-30T08:23:31Z","updated_at":"2016-08-30T08:23:32Z","html_url":"https://github.com/Sylius/Sylius/pull/5848#discussion_r76749990","pull_request_url":"https://api.github.com/repos/Sylius/Sylius/pulls/5848","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/76749990"},"html":{"href":"https://github.com/Sylius/Sylius/pull/5848#discussion_r76749990"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5848"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/5848","id":81969626,"html_url":"https://github.com/Sylius/Sylius/pull/5848","diff_url":"https://github.com/Sylius/Sylius/pull/5848.diff","patch_url":"https://github.com/Sylius/Sylius/pull/5848.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/5848","number":5848,"state":"open","locked":false,"title":"[WIP] [Documentation] Concepts: Shipments","user":{"login":"TheMadeleine","id":13198869,"avatar_url":"https://avatars.githubusercontent.com/u/13198869?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMadeleine","html_url":"https://github.com/TheMadeleine","followers_url":"https://api.github.com/users/TheMadeleine/followers","following_url":"https://api.github.com/users/TheMadeleine/following{/other_user}","gists_url":"https://api.github.com/users/TheMadeleine/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMadeleine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMadeleine/subscriptions","organizations_url":"https://api.github.com/users/TheMadeleine/orgs","repos_url":"https://api.github.com/users/TheMadeleine/repos","events_url":"https://api.github.com/users/TheMadeleine/events{/privacy}","received_events_url":"https://api.github.com/users/TheMadeleine/received_events","type":"User","site_admin":false},"body":"| Q               | A\r\n| --------------- | ---\r\n| Doc fix?        | yes\r\n| New docs?    | no\r\n| BC breaks?      | no\r\n| Related tickets | partially #5275 \r\n| License         | MIT","created_at":"2016-08-19T11:57:17Z","updated_at":"2016-08-30T08:23:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"92fb7aa460530bd6b2ed5a1dc43421447bb9d2a1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius/pulls/5848/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius/pulls/5848/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/5848/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/abb83ce83fd95886f2244a64e0857bc9ce49570a","head":{"label":"TheMadeleine:docs/shipments","ref":"docs/shipments","sha":"abb83ce83fd95886f2244a64e0857bc9ce49570a","user":{"login":"TheMadeleine","id":13198869,"avatar_url":"https://avatars.githubusercontent.com/u/13198869?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMadeleine","html_url":"https://github.com/TheMadeleine","followers_url":"https://api.github.com/users/TheMadeleine/followers","following_url":"https://api.github.com/users/TheMadeleine/following{/other_user}","gists_url":"https://api.github.com/users/TheMadeleine/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMadeleine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMadeleine/subscriptions","organizations_url":"https://api.github.com/users/TheMadeleine/orgs","repos_url":"https://api.github.com/users/TheMadeleine/repos","events_url":"https://api.github.com/users/TheMadeleine/events{/privacy}","received_events_url":"https://api.github.com/users/TheMadeleine/received_events","type":"User","site_admin":false},"repo":{"id":42736498,"name":"Sylius","full_name":"TheMadeleine/Sylius","owner":{"login":"TheMadeleine","id":13198869,"avatar_url":"https://avatars.githubusercontent.com/u/13198869?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMadeleine","html_url":"https://github.com/TheMadeleine","followers_url":"https://api.github.com/users/TheMadeleine/followers","following_url":"https://api.github.com/users/TheMadeleine/following{/other_user}","gists_url":"https://api.github.com/users/TheMadeleine/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMadeleine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMadeleine/subscriptions","organizations_url":"https://api.github.com/users/TheMadeleine/orgs","repos_url":"https://api.github.com/users/TheMadeleine/repos","events_url":"https://api.github.com/users/TheMadeleine/events{/privacy}","received_events_url":"https://api.github.com/users/TheMadeleine/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TheMadeleine/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":true,"url":"https://api.github.com/repos/TheMadeleine/Sylius","forks_url":"https://api.github.com/repos/TheMadeleine/Sylius/forks","keys_url":"https://api.github.com/repos/TheMadeleine/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheMadeleine/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheMadeleine/Sylius/teams","hooks_url":"https://api.github.com/repos/TheMadeleine/Sylius/hooks","issue_events_url":"https://api.github.com/repos/TheMadeleine/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/TheMadeleine/Sylius/events","assignees_url":"https://api.github.com/repos/TheMadeleine/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/TheMadeleine/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/TheMadeleine/Sylius/tags","blobs_url":"https://api.github.com/repos/TheMadeleine/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheMadeleine/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheMadeleine/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheMadeleine/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheMadeleine/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/TheMadeleine/Sylius/languages","stargazers_url":"https://api.github.com/repos/TheMadeleine/Sylius/stargazers","contributors_url":"https://api.github.com/repos/TheMadeleine/Sylius/contributors","subscribers_url":"https://api.github.com/repos/TheMadeleine/Sylius/subscribers","subscription_url":"https://api.github.com/repos/TheMadeleine/Sylius/subscription","commits_url":"https://api.github.com/repos/TheMadeleine/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheMadeleine/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheMadeleine/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheMadeleine/Sylius/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheMadeleine/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/TheMadeleine/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheMadeleine/Sylius/merges","archive_url":"https://api.github.com/repos/TheMadeleine/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheMadeleine/Sylius/downloads","issues_url":"https://api.github.com/repos/TheMadeleine/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/TheMadeleine/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/TheMadeleine/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/TheMadeleine/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheMadeleine/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/TheMadeleine/Sylius/releases{/id}","deployments_url":"https://api.github.com/repos/TheMadeleine/Sylius/deployments","created_at":"2015-09-18T17:21:15Z","updated_at":"2016-01-12T12:07:54Z","pushed_at":"2016-08-30T07:16:35Z","git_url":"git://github.com/TheMadeleine/Sylius.git","ssh_url":"git@github.com:TheMadeleine/Sylius.git","clone_url":"https://github.com/TheMadeleine/Sylius.git","svn_url":"https://github.com/TheMadeleine/Sylius","homepage":"Sylius.org","size":43777,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Sylius:master","ref":"master","sha":"66d152dc69a8111788a17a0a8374e910030ee39c","user":{"login":"Sylius","id":719423,"avatar_url":"https://avatars.githubusercontent.com/u/719423?v=3","gravatar_id":"","url":"https://api.github.com/users/Sylius","html_url":"https://github.com/Sylius","followers_url":"https://api.github.com/users/Sylius/followers","following_url":"https://api.github.com/users/Sylius/following{/other_user}","gists_url":"https://api.github.com/users/Sylius/gists{/gist_id}","starred_url":"https://api.github.com/users/Sylius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sylius/subscriptions","organizations_url":"https://api.github.com/users/Sylius/orgs","repos_url":"https://api.github.com/users/Sylius/repos","events_url":"https://api.github.com/users/Sylius/events{/privacy}","received_events_url":"https://api.github.com/users/Sylius/received_events","type":"Organization","site_admin":false},"repo":{"id":2717549,"name":"Sylius","full_name":"Sylius/Sylius","owner":{"login":"Sylius","id":719423,"avatar_url":"https://avatars.githubusercontent.com/u/719423?v=3","gravatar_id":"","url":"https://api.github.com/users/Sylius","html_url":"https://github.com/Sylius","followers_url":"https://api.github.com/users/Sylius/followers","following_url":"https://api.github.com/users/Sylius/following{/other_user}","gists_url":"https://api.github.com/users/Sylius/gists{/gist_id}","starred_url":"https://api.github.com/users/Sylius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sylius/subscriptions","organizations_url":"https://api.github.com/users/Sylius/orgs","repos_url":"https://api.github.com/users/Sylius/repos","events_url":"https://api.github.com/users/Sylius/events{/privacy}","received_events_url":"https://api.github.com/users/Sylius/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sylius/Sylius","description":"eCommerce PHP framework built on top of Symfony with component-based architecture and format-agnostic rendering. (HTML/JSON/XML)","fork":false,"url":"https://api.github.com/repos/Sylius/Sylius","forks_url":"https://api.github.com/repos/Sylius/Sylius/forks","keys_url":"https://api.github.com/repos/Sylius/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sylius/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sylius/Sylius/teams","hooks_url":"https://api.github.com/repos/Sylius/Sylius/hooks","issue_events_url":"https://api.github.com/repos/Sylius/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/Sylius/Sylius/events","assignees_url":"https://api.github.com/repos/Sylius/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/Sylius/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/Sylius/Sylius/tags","blobs_url":"https://api.github.com/repos/Sylius/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sylius/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sylius/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sylius/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/Sylius/Sylius/languages","stargazers_url":"https://api.github.com/repos/Sylius/Sylius/stargazers","contributors_url":"https://api.github.com/repos/Sylius/Sylius/contributors","subscribers_url":"https://api.github.com/repos/Sylius/Sylius/subscribers","subscription_url":"https://api.github.com/repos/Sylius/Sylius/subscription","commits_url":"https://api.github.com/repos/Sylius/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sylius/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sylius/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sylius/Sylius/issues/comments{/number}","contents_url":"https://api.github.com/repos/Sylius/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/Sylius/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sylius/Sylius/merges","archive_url":"https://api.github.com/repos/Sylius/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sylius/Sylius/downloads","issues_url":"https://api.github.com/repos/Sylius/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/Sylius/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/Sylius/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/Sylius/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sylius/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/Sylius/Sylius/releases{/id}","deployments_url":"https://api.github.com/repos/Sylius/Sylius/deployments","created_at":"2011-11-05T22:05:52Z","updated_at":"2016-08-29T14:15:18Z","pushed_at":"2016-08-30T08:17:17Z","git_url":"git://github.com/Sylius/Sylius.git","ssh_url":"git@github.com:Sylius/Sylius.git","clone_url":"https://github.com/Sylius/Sylius.git","svn_url":"https://github.com/Sylius/Sylius","homepage":"http://Sylius.org","size":77326,"stargazers_count":2429,"watchers_count":2429,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":909,"mirror_url":null,"open_issues_count":812,"forks":909,"open_issues":812,"watchers":2429,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5848"},"html":{"href":"https://github.com/Sylius/Sylius/pull/5848"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/5848"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/5848/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5848/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5848/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius/statuses/abb83ce83fd95886f2244a64e0857bc9ce49570a"}}}}
{"actor":{"display_login":"pjedrzejewski"}}