WC_Order_Item_Product::set_product()publicWC 1.0

Set properties based on passed in product object.

Method of the class: WC_Order_Item_Product{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Order_Item_Product = new WC_Order_Item_Product();
$WC_Order_Item_Product->set_product( $product );
$product(WC_Product) (required)
Product instance.

WC_Order_Item_Product::set_product() code WC 9.4.2

public function set_product( $product ) {
	if ( ! is_a( $product, 'WC_Product' ) ) {
		$this->error( 'order_item_product_invalid_product', __( 'Invalid product', 'woocommerce' ) );
	}
	if ( $product->is_type( 'variation' ) ) {
		$this->set_product_id( $product->get_parent_id() );
		$this->set_variation_id( $product->get_id() );
		$this->set_variation( is_callable( array( $product, 'get_variation_attributes' ) ) ? $product->get_variation_attributes() : array() );
	} else {
		$this->set_product_id( $product->get_id() );
	}
	$this->set_name( $product->get_name() );
	$this->set_tax_class( $product->get_tax_class() );
}