WC_Product::is_viewable
Whether the current user can view this product: it is published, or they can edit it. A variation additionally requires its parent to be viewable.
Метод класса: WC_Product{}
Хуков нет.
Возвращает
bool.
Использование
$WC_Product = new WC_Product(); $WC_Product->is_viewable();
Список изменений
| С версии 11.1.0 | Введена. |
Код WC_Product::is_viewable() WC Product::is viewable WC 11.1.2
public function is_viewable() {
$parent_id = $this->get_parent_id();
return ( ProductStatus::PUBLISH === $this->get_status() || current_user_can( 'edit_post', $this->get_id() ) )
&& ( ! $parent_id || ProductStatus::PUBLISH === get_post_status( $parent_id ) || current_user_can( 'edit_post', $parent_id ) );
}