Only allow those who can edit the post to add drafts to cart. For testing. Closes #3381

This commit is contained in:
Mike Jolley 2013-06-28 11:14:21 +01:00
parent e6db7d2c0c
commit a9569ccd6f
2 changed files with 5 additions and 1 deletions

View File

@ -708,6 +708,10 @@ class WC_Product {
elseif ( $this->get_price() === '' )
$purchasable = false;
// Check the product is published
elseif ( $this->post->post_status !== 'publish' && ! current_user_can( 'edit_post', $this->id ) )
$purchasable = false;
return apply_filters( 'woocommerce_is_purchasable', $purchasable, $this );
}

View File

@ -321,7 +321,7 @@ class WC_Cart {
// Check item stock
$result = $this->check_cart_item_stock();
if (is_wp_error($result))
if ( is_wp_error( $result ) )
wc_add_error( $result->get_error_message() );
}