{"action":"created","comment":{"url":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/comments/73733678","id":73733678,"diff_hunk":"@@ -465,47 +465,82 @@ public function postProcess()\n             ShopUrl::cacheMainDomainForShop((int)$order->id_shop);\n         }\n \n-        /* Update shipping number */\n+        /* Update shipping number and carrier */\n         if (Tools::isSubmit('submitShippingNumber') && isset($order)) {\n             if ($this->access('edit')) {\n+                $tracking_number = Tools::getValue('shipping_tracking_number');\n+                $id_carrier = Tools::getValue('shipping_carrier');\n+                $old_tracking_number = $order->shipping_number;\n+\n                 $order_carrier = new OrderCarrier(Tools::getValue('id_order_carrier'));\n                 if (!Validate::isLoadedObject($order_carrier)) {\n                     $this->errors[] = $this->trans('The order carrier ID is invalid.', array(), 'Admin.OrdersCustomers.Notification');\n-                } elseif (!Validate::isTrackingNumber(Tools::getValue('tracking_number'))) {\n+                } elseif (!empty($tracking_number) && !Validate::isTrackingNumber($tracking_number)) {\n                     $this->errors[] = $this->trans('The tracking number is incorrect.', array(), 'Admin.OrdersCustomers.Notification');\n                 } else {\n+                    //update carrier - ONLY if changed - then refresh shipping cost\n+                    $old_id_carrier = $order_carrier->id_carrier;\n+                    if (!empty($id_carrier) && $old_id_carrier != $id_carrier) {\n+                        $order->id_carrier = (int) $id_carrier;\n+                        $order_carrier->id_carrier = (int) $id_carrier;\n+                        $order_carrier->update();\n+                        $order->refreshShippingCost();\n+                    }\n+\n+                    //load fresh order carrier because updated just before\n+                    $order_carrier = new OrderCarrier((int) Tools::getValue('id_order_carrier'));\n+                    \n                     // update shipping number\n                     // Keep these two following lines for backward compatibility, remove on 1.6 version\n-                    $order->shipping_number = Tools::getValue('tracking_number');\n+                    $order->shipping_number = $tracking_number;","path":"controllers/admin/AdminOrdersController.php","position":34,"original_position":34,"commit_id":"b34f5f13ca9fd38f6cb8482de70b2fa12a5aa1a5","original_commit_id":"b34f5f13ca9fd38f6cb8482de70b2fa12a5aa1a5","user":{"login":"firstred","id":6775736,"avatar_url":"https://avatars.githubusercontent.com/u/6775736?v=3","gravatar_id":"","url":"https://api.github.com/users/firstred","html_url":"https://github.com/firstred","followers_url":"https://api.github.com/users/firstred/followers","following_url":"https://api.github.com/users/firstred/following{/other_user}","gists_url":"https://api.github.com/users/firstred/gists{/gist_id}","starred_url":"https://api.github.com/users/firstred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firstred/subscriptions","organizations_url":"https://api.github.com/users/firstred/orgs","repos_url":"https://api.github.com/users/firstred/repos","events_url":"https://api.github.com/users/firstred/events{/privacy}","received_events_url":"https://api.github.com/users/firstred/received_events","type":"User","site_admin":false},"body":"Why no `pSQL` for this one, or is this due to the previous inconsistency?","created_at":"2016-08-05T17:56:08Z","updated_at":"2016-08-05T17:56:08Z","html_url":"https://github.com/PrestaShop/PrestaShop/pull/5955#discussion_r73733678","pull_request_url":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/5955","_links":{"self":{"href":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/comments/73733678"},"html":{"href":"https://github.com/PrestaShop/PrestaShop/pull/5955#discussion_r73733678"},"pull_request":{"href":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/5955"}}},"pull_request":{"url":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/5955","id":80272485,"html_url":"https://github.com/PrestaShop/PrestaShop/pull/5955","diff_url":"https://github.com/PrestaShop/PrestaShop/pull/5955.diff","patch_url":"https://github.com/PrestaShop/PrestaShop/pull/5955.patch","issue_url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/5955","number":5955,"state":"open","locked":false,"title":"Option to change the Carrier on existing order","user":{"login":"kpodemski","id":2137763,"avatar_url":"https://avatars.githubusercontent.com/u/2137763?v=3","gravatar_id":"","url":"https://api.github.com/users/kpodemski","html_url":"https://github.com/kpodemski","followers_url":"https://api.github.com/users/kpodemski/followers","following_url":"https://api.github.com/users/kpodemski/following{/other_user}","gists_url":"https://api.github.com/users/kpodemski/gists{/gist_id}","starred_url":"https://api.github.com/users/kpodemski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kpodemski/subscriptions","organizations_url":"https://api.github.com/users/kpodemski/orgs","repos_url":"https://api.github.com/users/kpodemski/repos","events_url":"https://api.github.com/users/kpodemski/events{/privacy}","received_events_url":"https://api.github.com/users/kpodemski/received_events","type":"User","site_admin":false},"body":"<!-- Thank you for contributing to the PrestaShop project! \r\n\r\nPlease take the time to edit the \"Answers\" rows with the necessary information: -->\r\n\r\n| Questions     | Answers\r\n| ------------- | -------------------------------------------------------\r\n| Branch?       | develop\r\n| Description?  | This is rework of #4447 but with number of significant improvements\r\n| Type?         | improvement\r\n| Category?     | BO\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Fixed ticket? | many feature requests i guess :)\r\n| How to test?  | Try to change the carrier on existing order and check if everything is ok","created_at":"2016-08-05T16:40:43Z","updated_at":"2016-08-05T17:56:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7507920db9707d502a5a202fd1436ccfbc5243e4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/5955/commits","review_comments_url":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/5955/comments","review_comment_url":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/5955/comments","statuses_url":"https://api.github.com/repos/PrestaShop/PrestaShop/statuses/b34f5f13ca9fd38f6cb8482de70b2fa12a5aa1a5","head":{"label":"kpodemski:edit-shipping","ref":"edit-shipping","sha":"b34f5f13ca9fd38f6cb8482de70b2fa12a5aa1a5","user":{"login":"kpodemski","id":2137763,"avatar_url":"https://avatars.githubusercontent.com/u/2137763?v=3","gravatar_id":"","url":"https://api.github.com/users/kpodemski","html_url":"https://github.com/kpodemski","followers_url":"https://api.github.com/users/kpodemski/followers","following_url":"https://api.github.com/users/kpodemski/following{/other_user}","gists_url":"https://api.github.com/users/kpodemski/gists{/gist_id}","starred_url":"https://api.github.com/users/kpodemski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kpodemski/subscriptions","organizations_url":"https://api.github.com/users/kpodemski/orgs","repos_url":"https://api.github.com/users/kpodemski/repos","events_url":"https://api.github.com/users/kpodemski/events{/privacy}","received_events_url":"https://api.github.com/users/kpodemski/received_events","type":"User","site_admin":false},"repo":{"id":30925768,"name":"PrestaShop","full_name":"kpodemski/PrestaShop","owner":{"login":"kpodemski","id":2137763,"avatar_url":"https://avatars.githubusercontent.com/u/2137763?v=3","gravatar_id":"","url":"https://api.github.com/users/kpodemski","html_url":"https://github.com/kpodemski","followers_url":"https://api.github.com/users/kpodemski/followers","following_url":"https://api.github.com/users/kpodemski/following{/other_user}","gists_url":"https://api.github.com/users/kpodemski/gists{/gist_id}","starred_url":"https://api.github.com/users/kpodemski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kpodemski/subscriptions","organizations_url":"https://api.github.com/users/kpodemski/orgs","repos_url":"https://api.github.com/users/kpodemski/repos","events_url":"https://api.github.com/users/kpodemski/events{/privacy}","received_events_url":"https://api.github.com/users/kpodemski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kpodemski/PrestaShop","description":"PrestaShop offers a free, fully scalable, Open-source e-commerce solution.","fork":true,"url":"https://api.github.com/repos/kpodemski/PrestaShop","forks_url":"https://api.github.com/repos/kpodemski/PrestaShop/forks","keys_url":"https://api.github.com/repos/kpodemski/PrestaShop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kpodemski/PrestaShop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kpodemski/PrestaShop/teams","hooks_url":"https://api.github.com/repos/kpodemski/PrestaShop/hooks","issue_events_url":"https://api.github.com/repos/kpodemski/PrestaShop/issues/events{/number}","events_url":"https://api.github.com/repos/kpodemski/PrestaShop/events","assignees_url":"https://api.github.com/repos/kpodemski/PrestaShop/assignees{/user}","branches_url":"https://api.github.com/repos/kpodemski/PrestaShop/branches{/branch}","tags_url":"https://api.github.com/repos/kpodemski/PrestaShop/tags","blobs_url":"https://api.github.com/repos/kpodemski/PrestaShop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kpodemski/PrestaShop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kpodemski/PrestaShop/git/refs{/sha}","trees_url":"https://api.github.com/repos/kpodemski/PrestaShop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kpodemski/PrestaShop/statuses/{sha}","languages_url":"https://api.github.com/repos/kpodemski/PrestaShop/languages","stargazers_url":"https://api.github.com/repos/kpodemski/PrestaShop/stargazers","contributors_url":"https://api.github.com/repos/kpodemski/PrestaShop/contributors","subscribers_url":"https://api.github.com/repos/kpodemski/PrestaShop/subscribers","subscription_url":"https://api.github.com/repos/kpodemski/PrestaShop/subscription","commits_url":"https://api.github.com/repos/kpodemski/PrestaShop/commits{/sha}","git_commits_url":"https://api.github.com/repos/kpodemski/PrestaShop/git/commits{/sha}","comments_url":"https://api.github.com/repos/kpodemski/PrestaShop/comments{/number}","issue_comment_url":"https://api.github.com/repos/kpodemski/PrestaShop/issues/comments{/number}","contents_url":"https://api.github.com/repos/kpodemski/PrestaShop/contents/{+path}","compare_url":"https://api.github.com/repos/kpodemski/PrestaShop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kpodemski/PrestaShop/merges","archive_url":"https://api.github.com/repos/kpodemski/PrestaShop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kpodemski/PrestaShop/downloads","issues_url":"https://api.github.com/repos/kpodemski/PrestaShop/issues{/number}","pulls_url":"https://api.github.com/repos/kpodemski/PrestaShop/pulls{/number}","milestones_url":"https://api.github.com/repos/kpodemski/PrestaShop/milestones{/number}","notifications_url":"https://api.github.com/repos/kpodemski/PrestaShop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kpodemski/PrestaShop/labels{/name}","releases_url":"https://api.github.com/repos/kpodemski/PrestaShop/releases{/id}","deployments_url":"https://api.github.com/repos/kpodemski/PrestaShop/deployments","created_at":"2015-02-17T16:28:07Z","updated_at":"2015-04-03T15:31:12Z","pushed_at":"2016-08-05T16:38:16Z","git_url":"git://github.com/kpodemski/PrestaShop.git","ssh_url":"git@github.com:kpodemski/PrestaShop.git","clone_url":"https://github.com/kpodemski/PrestaShop.git","svn_url":"https://github.com/kpodemski/PrestaShop","homepage":"http://www.prestashop.com/","size":247230,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"1.6"}},"base":{"label":"PrestaShop:develop","ref":"develop","sha":"fc84ae968d0ab918302429a2e8e55f84363c3dc3","user":{"login":"PrestaShop","id":2815696,"avatar_url":"https://avatars.githubusercontent.com/u/2815696?v=3","gravatar_id":"","url":"https://api.github.com/users/PrestaShop","html_url":"https://github.com/PrestaShop","followers_url":"https://api.github.com/users/PrestaShop/followers","following_url":"https://api.github.com/users/PrestaShop/following{/other_user}","gists_url":"https://api.github.com/users/PrestaShop/gists{/gist_id}","starred_url":"https://api.github.com/users/PrestaShop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PrestaShop/subscriptions","organizations_url":"https://api.github.com/users/PrestaShop/orgs","repos_url":"https://api.github.com/users/PrestaShop/repos","events_url":"https://api.github.com/users/PrestaShop/events{/privacy}","received_events_url":"https://api.github.com/users/PrestaShop/received_events","type":"Organization","site_admin":false},"repo":{"id":6763587,"name":"PrestaShop","full_name":"PrestaShop/PrestaShop","owner":{"login":"PrestaShop","id":2815696,"avatar_url":"https://avatars.githubusercontent.com/u/2815696?v=3","gravatar_id":"","url":"https://api.github.com/users/PrestaShop","html_url":"https://github.com/PrestaShop","followers_url":"https://api.github.com/users/PrestaShop/followers","following_url":"https://api.github.com/users/PrestaShop/following{/other_user}","gists_url":"https://api.github.com/users/PrestaShop/gists{/gist_id}","starred_url":"https://api.github.com/users/PrestaShop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PrestaShop/subscriptions","organizations_url":"https://api.github.com/users/PrestaShop/orgs","repos_url":"https://api.github.com/users/PrestaShop/repos","events_url":"https://api.github.com/users/PrestaShop/events{/privacy}","received_events_url":"https://api.github.com/users/PrestaShop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PrestaShop/PrestaShop","description":"PrestaShop offers a free, fully scalable, Open Source e-commerce solution.","fork":false,"url":"https://api.github.com/repos/PrestaShop/PrestaShop","forks_url":"https://api.github.com/repos/PrestaShop/PrestaShop/forks","keys_url":"https://api.github.com/repos/PrestaShop/PrestaShop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PrestaShop/PrestaShop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PrestaShop/PrestaShop/teams","hooks_url":"https://api.github.com/repos/PrestaShop/PrestaShop/hooks","issue_events_url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/events{/number}","events_url":"https://api.github.com/repos/PrestaShop/PrestaShop/events","assignees_url":"https://api.github.com/repos/PrestaShop/PrestaShop/assignees{/user}","branches_url":"https://api.github.com/repos/PrestaShop/PrestaShop/branches{/branch}","tags_url":"https://api.github.com/repos/PrestaShop/PrestaShop/tags","blobs_url":"https://api.github.com/repos/PrestaShop/PrestaShop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PrestaShop/PrestaShop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PrestaShop/PrestaShop/git/refs{/sha}","trees_url":"https://api.github.com/repos/PrestaShop/PrestaShop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PrestaShop/PrestaShop/statuses/{sha}","languages_url":"https://api.github.com/repos/PrestaShop/PrestaShop/languages","stargazers_url":"https://api.github.com/repos/PrestaShop/PrestaShop/stargazers","contributors_url":"https://api.github.com/repos/PrestaShop/PrestaShop/contributors","subscribers_url":"https://api.github.com/repos/PrestaShop/PrestaShop/subscribers","subscription_url":"https://api.github.com/repos/PrestaShop/PrestaShop/subscription","commits_url":"https://api.github.com/repos/PrestaShop/PrestaShop/commits{/sha}","git_commits_url":"https://api.github.com/repos/PrestaShop/PrestaShop/git/commits{/sha}","comments_url":"https://api.github.com/repos/PrestaShop/PrestaShop/comments{/number}","issue_comment_url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/comments{/number}","contents_url":"https://api.github.com/repos/PrestaShop/PrestaShop/contents/{+path}","compare_url":"https://api.github.com/repos/PrestaShop/PrestaShop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PrestaShop/PrestaShop/merges","archive_url":"https://api.github.com/repos/PrestaShop/PrestaShop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PrestaShop/PrestaShop/downloads","issues_url":"https://api.github.com/repos/PrestaShop/PrestaShop/issues{/number}","pulls_url":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls{/number}","milestones_url":"https://api.github.com/repos/PrestaShop/PrestaShop/milestones{/number}","notifications_url":"https://api.github.com/repos/PrestaShop/PrestaShop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PrestaShop/PrestaShop/labels{/name}","releases_url":"https://api.github.com/repos/PrestaShop/PrestaShop/releases{/id}","deployments_url":"https://api.github.com/repos/PrestaShop/PrestaShop/deployments","created_at":"2012-11-19T16:41:31Z","updated_at":"2016-08-05T11:37:14Z","pushed_at":"2016-08-05T16:40:44Z","git_url":"git://github.com/PrestaShop/PrestaShop.git","ssh_url":"git@github.com:PrestaShop/PrestaShop.git","clone_url":"https://github.com/PrestaShop/PrestaShop.git","svn_url":"https://github.com/PrestaShop/PrestaShop","homepage":"http://www.prestashop.com/","size":317192,"stargazers_count":1921,"watchers_count":1921,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1959,"mirror_url":null,"open_issues_count":256,"forks":1959,"open_issues":256,"watchers":1921,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/5955"},"html":{"href":"https://github.com/PrestaShop/PrestaShop/pull/5955"},"issue":{"href":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/5955"},"comments":{"href":"https://api.github.com/repos/PrestaShop/PrestaShop/issues/5955/comments"},"review_comments":{"href":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/5955/comments"},"review_comment":{"href":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PrestaShop/PrestaShop/pulls/5955/commits"},"statuses":{"href":"https://api.github.com/repos/PrestaShop/PrestaShop/statuses/b34f5f13ca9fd38f6cb8482de70b2fa12a5aa1a5"}}}}
{"actor":{"display_login":"firstred"}}