{"action":"created","comment":{"url":"https://api.github.com/repos/woothemes/woocommerce/pulls/comments/53156520","id":53156520,"diff_hunk":"@@ -67,8 +67,10 @@ public function check_stock_status() {\n \t\t} elseif ( $this->backorders_allowed() || $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount' ) ) {\n \t\t\t$set_child_stock_status = 'instock';\n \t\t}\n+\t\t\n+\t\t$set_child_stock_status = apply_filters( 'woocommerce_product_check_stock_status', $set_child_stock_status, $this );","path":"includes/class-wc-product-variable.php","position":5,"original_position":5,"commit_id":"fe7066cbe82fe555ea418be52f201d89a64bb6e7","original_commit_id":"fe7066cbe82fe555ea418be52f201d89a64bb6e7","user":{"login":"ej52","id":6298706,"avatar_url":"https://avatars.githubusercontent.com/u/6298706?v=3","gravatar_id":"","url":"https://api.github.com/users/ej52","html_url":"https://github.com/ej52","followers_url":"https://api.github.com/users/ej52/followers","following_url":"https://api.github.com/users/ej52/following{/other_user}","gists_url":"https://api.github.com/users/ej52/gists{/gist_id}","starred_url":"https://api.github.com/users/ej52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ej52/subscriptions","organizations_url":"https://api.github.com/users/ej52/orgs","repos_url":"https://api.github.com/users/ej52/repos","events_url":"https://api.github.com/users/ej52/events{/privacy}","received_events_url":"https://api.github.com/users/ej52/received_events","type":"User","site_admin":false},"body":"Understood, this better?\r\n`woocommerce_product_stock_status_needs_change`","created_at":"2016-02-17T12:25:36Z","updated_at":"2016-02-17T12:25:36Z","html_url":"https://github.com/woothemes/woocommerce/pull/10104#discussion_r53156520","pull_request_url":"https://api.github.com/repos/woothemes/woocommerce/pulls/10104","_links":{"self":{"href":"https://api.github.com/repos/woothemes/woocommerce/pulls/comments/53156520"},"html":{"href":"https://github.com/woothemes/woocommerce/pull/10104#discussion_r53156520"},"pull_request":{"href":"https://api.github.com/repos/woothemes/woocommerce/pulls/10104"}}},"pull_request":{"url":"https://api.github.com/repos/woothemes/woocommerce/pulls/10104","id":56474936,"html_url":"https://github.com/woothemes/woocommerce/pull/10104","diff_url":"https://github.com/woothemes/woocommerce/pull/10104.diff","patch_url":"https://github.com/woothemes/woocommerce/pull/10104.patch","issue_url":"https://api.github.com/repos/woothemes/woocommerce/issues/10104","number":10104,"state":"open","locked":false,"title":"Allow custom stock statuses","user":{"login":"ej52","id":6298706,"avatar_url":"https://avatars.githubusercontent.com/u/6298706?v=3","gravatar_id":"","url":"https://api.github.com/users/ej52","html_url":"https://github.com/ej52","followers_url":"https://api.github.com/users/ej52/followers","following_url":"https://api.github.com/users/ej52/following{/other_user}","gists_url":"https://api.github.com/users/ej52/gists{/gist_id}","starred_url":"https://api.github.com/users/ej52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ej52/subscriptions","organizations_url":"https://api.github.com/users/ej52/orgs","repos_url":"https://api.github.com/users/ej52/repos","events_url":"https://api.github.com/users/ej52/events{/privacy}","received_events_url":"https://api.github.com/users/ej52/received_events","type":"User","site_admin":false},"body":"Follow on from https://github.com/woothemes/woocommerce/pull/10080.\r\n\r\nInstead of adding the discontinued status to the core, rather allow the addition of custom stock statuses with new WordPress filters.\r\n\r\n* woocommerce_stock_status_options\r\n* woocommerce_admin_column_stock_status\r\n* woocommerce_product_check_stock_status\r\n* woocommerce_product_is_in_stock\r\n* woocommerce_variation_is_in_stock\r\n\r\n\r\n**Example of adding a new custom stock status**\r\n\r\n```php\r\n// Add new stock status to select\r\nadd_filter( 'woocommerce_stock_status_options', function( $stock_statuses ) {\r\n\r\n\t$stock_statuses['discontinued'] = 'Discontinued';\r\n\treturn $stock_statuses;\r\n\r\n} );\r\n```\r\n```php\r\n// Add new stock status to columns in admin views\r\nadd_filter( 'woocommerce_admin_column_stock_status', function( $status, $product ) {\r\n\r\n\tif ( $product->stock_status === 'discontinued' ) {\r\n\t\treturn 'Discontinued';\r\n\t}\r\n\r\n\treturn $status;\r\n\r\n}, 10, 2 );\r\n```\r\n```php\r\n// Do nothing on stock status check for custom stock status\r\nadd_filter( 'woocommerce_product_check_stock_status', function( $status, $product ) {\r\n\r\n\tif ( $product->stock_status === 'discontinued' ) {\r\n\t\treturn '';\r\n\t}\r\n\r\n\treturn $status;\r\n\r\n}, 10, 2 );\r\n```\r\n```php\r\n// Is the product in stock?\r\nadd_filter( 'woocommerce_product_is_in_stock', function( $is_in_stock, $product ) {\r\n\r\n\tif ( $product->stock_status === 'discontinued' ) {\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn $is_in_stock;\r\n\r\n}, 10, 2 );\r\n```\r\n```php\r\n// Is the variation in stock?\r\nadd_filter( 'woocommerce_variation_is_in_stock', function( $is_in_stock, $variation ) {\r\n\r\n\tif ( $product->stock_status === 'discontinued' ) {\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn $is_in_stock;\r\n\r\n}, 10, 2 );\r\n```\r\n```php\r\n// Set the availability for custom stock status\r\nadd_filter( 'woocommerce_get_availability', function( $availability, $product ) {\r\n\r\n\tif ( $product->stock_status === 'discontinued' ) {\r\n\t\t$availability = array(\r\n\t\t\t'availability' \t=> 'Discontinued',\r\n\t\t\t'class' \t\t=> 'discontinued'\r\n\t\t);\r\n\t}\r\n\r\n\treturn $availability;\r\n\r\n}, 10, 2 );\r\n```","created_at":"2016-01-19T14:45:33Z","updated_at":"2016-02-17T12:25:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"504c3f916e57916fb7767829b470ca25d3294f49","assignee":null,"milestone":{"url":"https://api.github.com/repos/woothemes/woocommerce/milestones/51","html_url":"https://github.com/woothemes/woocommerce/milestones/2.6","labels_url":"https://api.github.com/repos/woothemes/woocommerce/milestones/51/labels","id":1425734,"number":51,"title":"2.6","description":"","creator":{"login":"mikejolley","id":90977,"avatar_url":"https://avatars.githubusercontent.com/u/90977?v=3","gravatar_id":"","url":"https://api.github.com/users/mikejolley","html_url":"https://github.com/mikejolley","followers_url":"https://api.github.com/users/mikejolley/followers","following_url":"https://api.github.com/users/mikejolley/following{/other_user}","gists_url":"https://api.github.com/users/mikejolley/gists{/gist_id}","starred_url":"https://api.github.com/users/mikejolley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikejolley/subscriptions","organizations_url":"https://api.github.com/users/mikejolley/orgs","repos_url":"https://api.github.com/users/mikejolley/repos","events_url":"https://api.github.com/users/mikejolley/events{/privacy}","received_events_url":"https://api.github.com/users/mikejolley/received_events","type":"User","site_admin":false},"open_issues":13,"closed_issues":49,"state":"open","created_at":"2015-11-23T18:25:09Z","updated_at":"2016-02-16T20:05:57Z","due_on":"2016-04-30T23:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/woothemes/woocommerce/pulls/10104/commits","review_comments_url":"https://api.github.com/repos/woothemes/woocommerce/pulls/10104/comments","review_comment_url":"https://api.github.com/repos/woothemes/woocommerce/pulls/comments{/number}","comments_url":"https://api.github.com/repos/woothemes/woocommerce/issues/10104/comments","statuses_url":"https://api.github.com/repos/woothemes/woocommerce/statuses/fe7066cbe82fe555ea418be52f201d89a64bb6e7","head":{"label":"ej52:custom-stock-statuses","ref":"custom-stock-statuses","sha":"fe7066cbe82fe555ea418be52f201d89a64bb6e7","user":{"login":"ej52","id":6298706,"avatar_url":"https://avatars.githubusercontent.com/u/6298706?v=3","gravatar_id":"","url":"https://api.github.com/users/ej52","html_url":"https://github.com/ej52","followers_url":"https://api.github.com/users/ej52/followers","following_url":"https://api.github.com/users/ej52/following{/other_user}","gists_url":"https://api.github.com/users/ej52/gists{/gist_id}","starred_url":"https://api.github.com/users/ej52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ej52/subscriptions","organizations_url":"https://api.github.com/users/ej52/orgs","repos_url":"https://api.github.com/users/ej52/repos","events_url":"https://api.github.com/users/ej52/events{/privacy}","received_events_url":"https://api.github.com/users/ej52/received_events","type":"User","site_admin":false},"repo":{"id":49949293,"name":"woocommerce","full_name":"ej52/woocommerce","owner":{"login":"ej52","id":6298706,"avatar_url":"https://avatars.githubusercontent.com/u/6298706?v=3","gravatar_id":"","url":"https://api.github.com/users/ej52","html_url":"https://github.com/ej52","followers_url":"https://api.github.com/users/ej52/followers","following_url":"https://api.github.com/users/ej52/following{/other_user}","gists_url":"https://api.github.com/users/ej52/gists{/gist_id}","starred_url":"https://api.github.com/users/ej52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ej52/subscriptions","organizations_url":"https://api.github.com/users/ej52/orgs","repos_url":"https://api.github.com/users/ej52/repos","events_url":"https://api.github.com/users/ej52/events{/privacy}","received_events_url":"https://api.github.com/users/ej52/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ej52/woocommerce","description":"An open source eCommerce plugin for WordPress created by WooThemes.","fork":true,"url":"https://api.github.com/repos/ej52/woocommerce","forks_url":"https://api.github.com/repos/ej52/woocommerce/forks","keys_url":"https://api.github.com/repos/ej52/woocommerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ej52/woocommerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ej52/woocommerce/teams","hooks_url":"https://api.github.com/repos/ej52/woocommerce/hooks","issue_events_url":"https://api.github.com/repos/ej52/woocommerce/issues/events{/number}","events_url":"https://api.github.com/repos/ej52/woocommerce/events","assignees_url":"https://api.github.com/repos/ej52/woocommerce/assignees{/user}","branches_url":"https://api.github.com/repos/ej52/woocommerce/branches{/branch}","tags_url":"https://api.github.com/repos/ej52/woocommerce/tags","blobs_url":"https://api.github.com/repos/ej52/woocommerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ej52/woocommerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ej52/woocommerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/ej52/woocommerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ej52/woocommerce/statuses/{sha}","languages_url":"https://api.github.com/repos/ej52/woocommerce/languages","stargazers_url":"https://api.github.com/repos/ej52/woocommerce/stargazers","contributors_url":"https://api.github.com/repos/ej52/woocommerce/contributors","subscribers_url":"https://api.github.com/repos/ej52/woocommerce/subscribers","subscription_url":"https://api.github.com/repos/ej52/woocommerce/subscription","commits_url":"https://api.github.com/repos/ej52/woocommerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/ej52/woocommerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/ej52/woocommerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/ej52/woocommerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/ej52/woocommerce/contents/{+path}","compare_url":"https://api.github.com/repos/ej52/woocommerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ej52/woocommerce/merges","archive_url":"https://api.github.com/repos/ej52/woocommerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ej52/woocommerce/downloads","issues_url":"https://api.github.com/repos/ej52/woocommerce/issues{/number}","pulls_url":"https://api.github.com/repos/ej52/woocommerce/pulls{/number}","milestones_url":"https://api.github.com/repos/ej52/woocommerce/milestones{/number}","notifications_url":"https://api.github.com/repos/ej52/woocommerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ej52/woocommerce/labels{/name}","releases_url":"https://api.github.com/repos/ej52/woocommerce/releases{/id}","deployments_url":"https://api.github.com/repos/ej52/woocommerce/deployments","created_at":"2016-01-19T11:50:51Z","updated_at":"2016-01-19T11:50:55Z","pushed_at":"2016-01-20T07:30:19Z","git_url":"git://github.com/ej52/woocommerce.git","ssh_url":"git@github.com:ej52/woocommerce.git","clone_url":"https://github.com/ej52/woocommerce.git","svn_url":"https://github.com/ej52/woocommerce","homepage":"http://www.woothemes.com/woocommerce/","size":109185,"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":"woothemes:master","ref":"master","sha":"44eac248b34455c7d2cc7f09792730563cd787c9","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}","deployments_url":"https://api.github.com/repos/woothemes/woocommerce/deployments","created_at":"2011-08-09T15:12:11Z","updated_at":"2016-02-17T09:17:44Z","pushed_at":"2016-02-17T12:04:04Z","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":115611,"stargazers_count":2551,"watchers_count":2551,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2048,"mirror_url":null,"open_issues_count":28,"forks":2048,"open_issues":28,"watchers":2551,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/woothemes/woocommerce/pulls/10104"},"html":{"href":"https://github.com/woothemes/woocommerce/pull/10104"},"issue":{"href":"https://api.github.com/repos/woothemes/woocommerce/issues/10104"},"comments":{"href":"https://api.github.com/repos/woothemes/woocommerce/issues/10104/comments"},"review_comments":{"href":"https://api.github.com/repos/woothemes/woocommerce/pulls/10104/comments"},"review_comment":{"href":"https://api.github.com/repos/woothemes/woocommerce/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/woothemes/woocommerce/pulls/10104/commits"},"statuses":{"href":"https://api.github.com/repos/woothemes/woocommerce/statuses/fe7066cbe82fe555ea418be52f201d89a64bb6e7"}}}}