{"action":"closed","number":8322,"pull_request":{"url":"https://api.github.com/repos/woothemes/woocommerce/pulls/8322","id":37185726,"html_url":"https://github.com/woothemes/woocommerce/pull/8322","diff_url":"https://github.com/woothemes/woocommerce/pull/8322.diff","patch_url":"https://github.com/woothemes/woocommerce/pull/8322.patch","issue_url":"https://api.github.com/repos/woothemes/woocommerce/issues/8322","number":8322,"state":"closed","locked":false,"title":"Take product variation into account when creating orders from the API (fixes #7951)","user":{"login":"justinshreve","id":689165,"avatar_url":"https://avatars.githubusercontent.com/u/689165?v=3","gravatar_id":"","url":"https://api.github.com/users/justinshreve","html_url":"https://github.com/justinshreve","followers_url":"https://api.github.com/users/justinshreve/followers","following_url":"https://api.github.com/users/justinshreve/following{/other_user}","gists_url":"https://api.github.com/users/justinshreve/gists{/gist_id}","starred_url":"https://api.github.com/users/justinshreve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinshreve/subscriptions","organizations_url":"https://api.github.com/users/justinshreve/orgs","repos_url":"https://api.github.com/users/justinshreve/repos","events_url":"https://api.github.com/users/justinshreve/events{/privacy}","received_events_url":"https://api.github.com/users/justinshreve/received_events","type":"User","site_admin":false},"body":"Fixes #7951.\r\n\r\nThe orders API does not take into account variation details (specifically things like price) when creating an order. This is because the correct product/id is not getting passed into the eventual `add_product` call.\r\n\r\nThe only way I could think of to get around this was to take the variation information that gets passed by the API (like size or chocolate as seen in #7951) and try to figure out the correct `variation_id` and load that as the product in `set_line_item`.\r\n\r\nPut another way:\r\n* API passes main parent product_id (per example in #7951)\r\n* API passes variation data like size\r\n* In `set_line_item`, while loading product data, check against all possible variations. If the data passed matches a variation, grab that ID\r\n* Set that ID as the product in `add_product` so all the correct information (like price) is passed\r\n\r\nThis seems to fix the issue. If no variation data is passed, the default product price/setting is used.\r\n\r\nI'm open to other suggestions if this doesn't make sense -- but we have to load the ID manually either way. Even if we an API dev pass the ID in with information like size, we would still need to do some checking to make sure that the attribute data matches with the variation (other wise you could request a 3XL tshirt but pass in the variation ID of a cheaper shirt). This also seems nicer since it doesn't require the dev to know yet another ID and existing API calls will work correctly.\r\n\r\n__Testing Steps__:\r\n\r\nI created a new test for this. `phpunit --filter=test_wc_api_order_get_variation_id_returns_correct_id`.","created_at":"2015-06-08T19:11:56Z","updated_at":"2015-06-09T14:20:44Z","closed_at":"2015-06-09T14:20:44Z","merged_at":"2015-06-09T14:20:44Z","merge_commit_sha":"5dc723e71b43f244323b21452b1f61add39b1fb4","assignee":{"login":"justinshreve","id":689165,"avatar_url":"https://avatars.githubusercontent.com/u/689165?v=3","gravatar_id":"","url":"https://api.github.com/users/justinshreve","html_url":"https://github.com/justinshreve","followers_url":"https://api.github.com/users/justinshreve/followers","following_url":"https://api.github.com/users/justinshreve/following{/other_user}","gists_url":"https://api.github.com/users/justinshreve/gists{/gist_id}","starred_url":"https://api.github.com/users/justinshreve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinshreve/subscriptions","organizations_url":"https://api.github.com/users/justinshreve/orgs","repos_url":"https://api.github.com/users/justinshreve/repos","events_url":"https://api.github.com/users/justinshreve/events{/privacy}","received_events_url":"https://api.github.com/users/justinshreve/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/woothemes/woocommerce/pulls/8322/commits","review_comments_url":"https://api.github.com/repos/woothemes/woocommerce/pulls/8322/comments","review_comment_url":"https://api.github.com/repos/woothemes/woocommerce/pulls/comments{/number}","comments_url":"https://api.github.com/repos/woothemes/woocommerce/issues/8322/comments","statuses_url":"https://api.github.com/repos/woothemes/woocommerce/statuses/651b65f28e0ba1c468120c52855281072dd082cf","head":{"label":"justinshreve:api-product-variation-7951","ref":"api-product-variation-7951","sha":"651b65f28e0ba1c468120c52855281072dd082cf","user":{"login":"justinshreve","id":689165,"avatar_url":"https://avatars.githubusercontent.com/u/689165?v=3","gravatar_id":"","url":"https://api.github.com/users/justinshreve","html_url":"https://github.com/justinshreve","followers_url":"https://api.github.com/users/justinshreve/followers","following_url":"https://api.github.com/users/justinshreve/following{/other_user}","gists_url":"https://api.github.com/users/justinshreve/gists{/gist_id}","starred_url":"https://api.github.com/users/justinshreve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinshreve/subscriptions","organizations_url":"https://api.github.com/users/justinshreve/orgs","repos_url":"https://api.github.com/users/justinshreve/repos","events_url":"https://api.github.com/users/justinshreve/events{/privacy}","received_events_url":"https://api.github.com/users/justinshreve/received_events","type":"User","site_admin":false},"repo":{"id":36830592,"name":"woocommerce","full_name":"justinshreve/woocommerce","owner":{"login":"justinshreve","id":689165,"avatar_url":"https://avatars.githubusercontent.com/u/689165?v=3","gravatar_id":"","url":"https://api.github.com/users/justinshreve","html_url":"https://github.com/justinshreve","followers_url":"https://api.github.com/users/justinshreve/followers","following_url":"https://api.github.com/users/justinshreve/following{/other_user}","gists_url":"https://api.github.com/users/justinshreve/gists{/gist_id}","starred_url":"https://api.github.com/users/justinshreve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinshreve/subscriptions","organizations_url":"https://api.github.com/users/justinshreve/orgs","repos_url":"https://api.github.com/users/justinshreve/repos","events_url":"https://api.github.com/users/justinshreve/events{/privacy}","received_events_url":"https://api.github.com/users/justinshreve/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/justinshreve/woocommerce","description":"An open source eCommerce plugin for WordPress created by WooThemes.","fork":true,"url":"https://api.github.com/repos/justinshreve/woocommerce","forks_url":"https://api.github.com/repos/justinshreve/woocommerce/forks","keys_url":"https://api.github.com/repos/justinshreve/woocommerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/justinshreve/woocommerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/justinshreve/woocommerce/teams","hooks_url":"https://api.github.com/repos/justinshreve/woocommerce/hooks","issue_events_url":"https://api.github.com/repos/justinshreve/woocommerce/issues/events{/number}","events_url":"https://api.github.com/repos/justinshreve/woocommerce/events","assignees_url":"https://api.github.com/repos/justinshreve/woocommerce/assignees{/user}","branches_url":"https://api.github.com/repos/justinshreve/woocommerce/branches{/branch}","tags_url":"https://api.github.com/repos/justinshreve/woocommerce/tags","blobs_url":"https://api.github.com/repos/justinshreve/woocommerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/justinshreve/woocommerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/justinshreve/woocommerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/justinshreve/woocommerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/justinshreve/woocommerce/statuses/{sha}","languages_url":"https://api.github.com/repos/justinshreve/woocommerce/languages","stargazers_url":"https://api.github.com/repos/justinshreve/woocommerce/stargazers","contributors_url":"https://api.github.com/repos/justinshreve/woocommerce/contributors","subscribers_url":"https://api.github.com/repos/justinshreve/woocommerce/subscribers","subscription_url":"https://api.github.com/repos/justinshreve/woocommerce/subscription","commits_url":"https://api.github.com/repos/justinshreve/woocommerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/justinshreve/woocommerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/justinshreve/woocommerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/justinshreve/woocommerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/justinshreve/woocommerce/contents/{+path}","compare_url":"https://api.github.com/repos/justinshreve/woocommerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/justinshreve/woocommerce/merges","archive_url":"https://api.github.com/repos/justinshreve/woocommerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/justinshreve/woocommerce/downloads","issues_url":"https://api.github.com/repos/justinshreve/woocommerce/issues{/number}","pulls_url":"https://api.github.com/repos/justinshreve/woocommerce/pulls{/number}","milestones_url":"https://api.github.com/repos/justinshreve/woocommerce/milestones{/number}","notifications_url":"https://api.github.com/repos/justinshreve/woocommerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/justinshreve/woocommerce/labels{/name}","releases_url":"https://api.github.com/repos/justinshreve/woocommerce/releases{/id}","created_at":"2015-06-03T21:05:53Z","updated_at":"2015-06-04T13:58:01Z","pushed_at":"2015-06-09T13:38:44Z","git_url":"git://github.com/justinshreve/woocommerce.git","ssh_url":"git@github.com:justinshreve/woocommerce.git","clone_url":"https://github.com/justinshreve/woocommerce.git","svn_url":"https://github.com/justinshreve/woocommerce","homepage":"http://www.woothemes.com/woocommerce/","size":102133,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"woothemes:master","ref":"master","sha":"eb4b9a7cd18141a4d8777fbc01713c4db77eec45","user":{"login":"woothemes","id":473596,"avatar_url":"https://avatars.githubusercontent.com/u/473596?v=3","gravatar_id":"","url":"https://api.github.com/users/woothemes","html_url":"https://github.com/woothemes","followers_url":"https://api.github.com/users/woothemes/followers","following_url":"https://api.github.com/users/woothemes/following{/other_user}","gists_url":"https://api.github.com/users/woothemes/gists{/gist_id}","starred_url":"https://api.github.com/users/woothemes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/woothemes/subscriptions","organizations_url":"https://api.github.com/users/woothemes/orgs","repos_url":"https://api.github.com/users/woothemes/repos","events_url":"https://api.github.com/users/woothemes/events{/privacy}","received_events_url":"https://api.github.com/users/woothemes/received_events","type":"Organization","site_admin":false},"repo":{"id":2179920,"name":"woocommerce","full_name":"woothemes/woocommerce","owner":{"login":"woothemes","id":473596,"avatar_url":"https://avatars.githubusercontent.com/u/473596?v=3","gravatar_id":"","url":"https://api.github.com/users/woothemes","html_url":"https://github.com/woothemes","followers_url":"https://api.github.com/users/woothemes/followers","following_url":"https://api.github.com/users/woothemes/following{/other_user}","gists_url":"https://api.github.com/users/woothemes/gists{/gist_id}","starred_url":"https://api.github.com/users/woothemes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/woothemes/subscriptions","organizations_url":"https://api.github.com/users/woothemes/orgs","repos_url":"https://api.github.com/users/woothemes/repos","events_url":"https://api.github.com/users/woothemes/events{/privacy}","received_events_url":"https://api.github.com/users/woothemes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/woothemes/woocommerce","description":"An open source eCommerce plugin for WordPress created by WooThemes.","fork":false,"url":"https://api.github.com/repos/woothemes/woocommerce","forks_url":"https://api.github.com/repos/woothemes/woocommerce/forks","keys_url":"https://api.github.com/repos/woothemes/woocommerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/woothemes/woocommerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/woothemes/woocommerce/teams","hooks_url":"https://api.github.com/repos/woothemes/woocommerce/hooks","issue_events_url":"https://api.github.com/repos/woothemes/woocommerce/issues/events{/number}","events_url":"https://api.github.com/repos/woothemes/woocommerce/events","assignees_url":"https://api.github.com/repos/woothemes/woocommerce/assignees{/user}","branches_url":"https://api.github.com/repos/woothemes/woocommerce/branches{/branch}","tags_url":"https://api.github.com/repos/woothemes/woocommerce/tags","blobs_url":"https://api.github.com/repos/woothemes/woocommerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/woothemes/woocommerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/woothemes/woocommerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/woothemes/woocommerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/woothemes/woocommerce/statuses/{sha}","languages_url":"https://api.github.com/repos/woothemes/woocommerce/languages","stargazers_url":"https://api.github.com/repos/woothemes/woocommerce/stargazers","contributors_url":"https://api.github.com/repos/woothemes/woocommerce/contributors","subscribers_url":"https://api.github.com/repos/woothemes/woocommerce/subscribers","subscription_url":"https://api.github.com/repos/woothemes/woocommerce/subscription","commits_url":"https://api.github.com/repos/woothemes/woocommerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/woothemes/woocommerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/woothemes/woocommerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/woothemes/woocommerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/woothemes/woocommerce/contents/{+path}","compare_url":"https://api.github.com/repos/woothemes/woocommerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/woothemes/woocommerce/merges","archive_url":"https://api.github.com/repos/woothemes/woocommerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/woothemes/woocommerce/downloads","issues_url":"https://api.github.com/repos/woothemes/woocommerce/issues{/number}","pulls_url":"https://api.github.com/repos/woothemes/woocommerce/pulls{/number}","milestones_url":"https://api.github.com/repos/woothemes/woocommerce/milestones{/number}","notifications_url":"https://api.github.com/repos/woothemes/woocommerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/woothemes/woocommerce/labels{/name}","releases_url":"https://api.github.com/repos/woothemes/woocommerce/releases{/id}","created_at":"2011-08-09T15:12:11Z","updated_at":"2015-06-09T10:54:22Z","pushed_at":"2015-06-09T14:20:44Z","git_url":"git://github.com/woothemes/woocommerce.git","ssh_url":"git@github.com:woothemes/woocommerce.git","clone_url":"https://github.com/woothemes/woocommerce.git","svn_url":"https://github.com/woothemes/woocommerce","homepage":"http://www.woothemes.com/woocommerce/","size":131087,"stargazers_count":2087,"watchers_count":2087,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1625,"mirror_url":null,"open_issues_count":29,"forks":1625,"open_issues":29,"watchers":2087,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/woothemes/woocommerce/pulls/8322"},"html":{"href":"https://github.com/woothemes/woocommerce/pull/8322"},"issue":{"href":"https://api.github.com/repos/woothemes/woocommerce/issues/8322"},"comments":{"href":"https://api.github.com/repos/woothemes/woocommerce/issues/8322/comments"},"review_comments":{"href":"https://api.github.com/repos/woothemes/woocommerce/pulls/8322/comments"},"review_comment":{"href":"https://api.github.com/repos/woothemes/woocommerce/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/woothemes/woocommerce/pulls/8322/commits"},"statuses":{"href":"https://api.github.com/repos/woothemes/woocommerce/statuses/651b65f28e0ba1c468120c52855281072dd082cf"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"claudiosmweb","id":1264099,"avatar_url":"https://avatars.githubusercontent.com/u/1264099?v=3","gravatar_id":"","url":"https://api.github.com/users/claudiosmweb","html_url":"https://github.com/claudiosmweb","followers_url":"https://api.github.com/users/claudiosmweb/followers","following_url":"https://api.github.com/users/claudiosmweb/following{/other_user}","gists_url":"https://api.github.com/users/claudiosmweb/gists{/gist_id}","starred_url":"https://api.github.com/users/claudiosmweb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudiosmweb/subscriptions","organizations_url":"https://api.github.com/users/claudiosmweb/orgs","repos_url":"https://api.github.com/users/claudiosmweb/repos","events_url":"https://api.github.com/users/claudiosmweb/events{/privacy}","received_events_url":"https://api.github.com/users/claudiosmweb/received_events","type":"User","site_admin":false},"comments":0,"review_comments":0,"commits":3,"additions":111,"deletions":4,"changed_files":3}}