Automattic\WooCommerce\Internal\ShopperLists
ShopperListItem::get_product
Resolve the live product (or variation) backing this saved item.
Method of the class: ShopperListItem{}
No Hooks.
Returns
null. Nothing (null).
Usage
$ShopperListItem = new ShopperListItem(); $ShopperListItem->get_product(): ?\WC_Product;
ShopperListItem::get_product() ShopperListItem::get product code WC 10.9.1
public function get_product(): ?\WC_Product {
if ( $this->product instanceof \WC_Product ) {
return $this->product;
}
$id = $this->variation_id > 0 ? $this->variation_id : $this->product_id;
$product = $id > 0 ? wc_get_product( $id ) : false;
$this->product = $product instanceof \WC_Product ? $product : null;
return $this->product;
}