WC_Product_Variation::is_purchasable
Returns false if the product cannot be bought. Override abstract method so that: i) Disabled variations are not be purchasable by admins. ii) Enabled variations are not purchasable if the parent product is not purchasable.
Метод класса: WC_Product_Variation{}
Хуки из метода
Возвращает
true|false
.
Использование
$WC_Product_Variation = new WC_Product_Variation(); $WC_Product_Variation->is_purchasable();
Код WC_Product_Variation::is_purchasable() WC Product Variation::is purchasable WC 9.9.3
public function is_purchasable() { /** * Filter to adjust if a variation is purchasable. * * @since 3.0.0 * @param bool $purchasable If the variation is purchasable. * @param object $variation The variation object. */ return apply_filters( 'woocommerce_variation_is_purchasable', $this->variation_is_visible() && parent::is_purchasable() && ( ProductStatus::PUBLISH === $this->parent_data['status'] || current_user_can( 'edit_post', $this->get_parent_id() ) ), $this ); }