__construct() public method

Merges variable product data into the parent object.
public __construct ( integer | WC_Product | object $product )
$product integer | WC_Product | object Product to init.
 /**
  * Create a simple subscription product object.
  *
  * @access public
  * @param mixed $product
  */
 public function __construct($product)
 {
     parent::__construct($product);
     $this->product_type = 'variable-subscription';
     // Load all meta fields
     $this->product_custom_fields = get_post_meta($this->id);
     // Convert selected subscription meta fields for easy access
     if (!empty($this->product_custom_fields['_subscription_price'][0])) {
         $this->subscription_price = $this->product_custom_fields['_subscription_price'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_sign_up_fee'][0])) {
         $this->subscription_sign_up_fee = $this->product_custom_fields['_subscription_sign_up_fee'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_period'][0])) {
         $this->subscription_period = $this->product_custom_fields['_subscription_period'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_period_interval'][0])) {
         $this->subscription_period_interval = $this->product_custom_fields['_subscription_period_interval'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_length'][0])) {
         $this->subscription_length = $this->product_custom_fields['_subscription_length'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_trial_length'][0])) {
         $this->subscription_trial_length = $this->product_custom_fields['_subscription_trial_length'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_trial_period'][0])) {
         $this->subscription_trial_period = $this->product_custom_fields['_subscription_trial_period'][0];
     }
     $this->limit_subscriptions = !isset($this->product_custom_fields['_subscription_limit'][0]) ? 'no' : $this->product_custom_fields['_subscription_limit'][0];
     add_filter('woocommerce_add_to_cart_handler', array(&$this, 'add_to_cart_handler'), 10, 2);
 }
 /**
  * Create a variable registration product object.
  *
  * @access public
  * @param mixed $product
  */
 public function __construct($product)
 {
     parent::__construct($product);
     $this->parent_product_type = $this->product_type;
     $this->product_type = 'registrations';
     add_filter('woocommerce_add_to_cart_handler', array(&$this, 'add_to_cart_handler'), 10, 2);
 }
 /**
  * Construct.
  *
  * @access public
  * @param mixed $product
  */
 public function __construct($product)
 {
     parent::__construct($product);
     $this->product_type = 'tour';
     $this->virtual = 'yes';
     $this->downloadable = 'no';
 }
 /**
  * Create a simple subscription product object.
  *
  * @access public
  * @param mixed $product
  */
 public function __construct($product)
 {
     parent::__construct($product);
     $this->parent_product_type = $this->product_type;
     $this->product_type = 'variable-subscription';
     // Load all meta fields
     $this->product_custom_fields = get_post_meta($this->id);
     // Convert selected subscription meta fields for easy access
     if (!empty($this->product_custom_fields['_subscription_price'][0])) {
         $this->subscription_price = $this->product_custom_fields['_subscription_price'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_sign_up_fee'][0])) {
         $this->subscription_sign_up_fee = $this->product_custom_fields['_subscription_sign_up_fee'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_period'][0])) {
         $this->subscription_period = $this->product_custom_fields['_subscription_period'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_period_interval'][0])) {
         $this->subscription_period_interval = $this->product_custom_fields['_subscription_period_interval'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_length'][0])) {
         $this->subscription_length = $this->product_custom_fields['_subscription_length'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_trial_length'][0])) {
         $this->subscription_trial_length = $this->product_custom_fields['_subscription_trial_length'][0];
     }
     if (!empty($this->product_custom_fields['_subscription_trial_period'][0])) {
         $this->subscription_trial_period = $this->product_custom_fields['_subscription_trial_period'][0];
     }
     $this->subscription_payment_sync_date = 0;
     $this->subscription_one_time_shipping = !isset($this->product_custom_fields['_subscription_one_time_shipping'][0]) ? 'no' : $this->product_custom_fields['_subscription_one_time_shipping'][0];
     if (!isset($this->product_custom_fields['_subscription_limit'][0])) {
         $this->limit_subscriptions = 'no';
     } elseif ('yes' == $this->product_custom_fields['_subscription_limit'][0]) {
         // backward compatibility
         $this->limit_subscriptions = 'any';
     } else {
         $this->limit_subscriptions = $this->product_custom_fields['_subscription_limit'][0];
     }
     add_filter('woocommerce_add_to_cart_handler', array(&$this, 'add_to_cart_handler'), 10, 2);
 }