public function bySlug(string $slug, bool $no_cache = false)
    {
        $slug = (string) $slug;

        if (!($slug = (string) $slug)) {
            return null; // Not possible.
        } elseif (!($product_id = $this->idBySlug($slug, $no_cache))) {
            return null; // Not possible.
        } elseif (!($WC_Product = wc_get_product($product_id))) {
            return null; // Not possible.
        } elseif (!$WC_Product->exists()) {
            return null; // Not possible.
        }
        return $WC_Product;
    }
public function bySlug(string $slug, bool $no_cache = false)
    {
        $slug = (string) $slug;

        if (!($slug = (string) $slug)) {
            return null; // Not possible.
        } elseif (!($product_id = $this->idBySlug($slug, $no_cache))) {
            return null; // Not possible.
        } elseif (!($WC_Product = wc_get_product($product_id))) {
            return null; // Not possible.
        } elseif (!$WC_Product->exists()) {
            return null; // Not possible.
        }
        return $WC_Product;
    }
public function bySlug ( string $ slug , bool $ no_cache = false ) { $ slug = ( string ) $ slug ; if ( ! ( $ slug = ( string ) $ slug ) ) { return null ; // Not possible. } elseif ( ! ( $ product_id = $ this -> idBySlug ( $ slug , $ no_cache ) ) ) { return null ; // Not possible. } elseif ( ! ( $ WC_Product = wc_get_product ( $ product_id ) ) ) { return null ; // Not possible. } elseif ( ! $ WC_Product -> exists ( ) ) { return null ; // Not possible. } return $ WC_Product ; }
Product by slug.

@since 160727 WC product utils.

@param string $slug     Product slug.
@param bool   $no_cache Bypass cache check?

@return \WC_Product|null Product, else `null`.
Product by slug .