__construct() public method

This class should NOT be instantiated, but the wc_get_product() function should be used. It is possible, but the wc_get_product() is preferred.
public __construct ( integer | WC_Product | object $product )
$product integer | WC_Product | object Product to init.
 function __construct($bundle_id)
 {
     $this->product_type = 'composite';
     parent::__construct($bundle_id);
     $this->composite_data = get_post_meta($this->id, '_bto_data', true);
     $this->per_product_pricing = get_post_meta($this->id, '_per_product_pricing_bto', true);
     $this->per_product_shipping = get_post_meta($this->id, '_per_product_shipping_bto', true);
     $this->composite_layout = get_post_meta($this->id, '_bto_style', true);
     $this->selections_style = get_post_meta($this->id, '_bto_selection_mode', true);
     $this->contains_nyp = false;
     $this->has_discounts = false;
     $this->min_price = get_post_meta($this->id, '_min_composite_price', true);
     $this->max_price = get_post_meta($this->id, '_max_composite_price', true);
     $this->price_meta = (double) get_post_meta($this->id, '_price', true);
     $base_price = get_post_meta($this->id, '_base_price', true);
     $base_regular_price = get_post_meta($this->id, '_base_regular_price', true);
     $base_sale_price = get_post_meta($this->id, '_base_sale_price', true);
     $this->base_price = empty($base_price) ? 0.0 : (double) $base_price;
     $this->base_regular_price = empty($base_regular_price) ? 0.0 : (double) $base_regular_price;
     $this->base_sale_price = empty($base_sale_price) ? 0.0 : (double) $base_sale_price;
     $this->hide_price_html = get_post_meta($this->id, '_bto_hide_shop_price', true) == 'yes' ? true : false;
     if ($this->is_priced_per_product()) {
         $this->price = $this->get_base_price();
     }
 }
 public function __construct($bundle)
 {
     $this->product_type = 'bundle';
     parent::__construct($bundle);
     $this->bundle_data = get_post_meta($this->id, '_bundle_data', true);
     $bundled_item_ids = get_post_meta($this->id, '_bundled_ids', true);
     // Update from 3.X.
     if (empty($this->bundle_data) && !empty($bundled_item_ids)) {
         $this->bundle_data = WC_PB_Helpers::serialize_bundle_meta($this->id);
     }
     $this->contains_nyp = false;
     $this->is_nyp = false;
     $this->contains_sub = false;
     $this->contains_optional = false;
     $this->suppress_range_format = false;
     $this->on_sale = false;
     $this->items_require_input = false;
     $this->all_items_optional = true;
     $this->all_items_visible = true;
     $this->all_items_sold_individually = true;
     $this->all_items_in_stock = true;
     $this->all_items_purchasable = true;
     $this->has_items_on_backorder = false;
     $this->per_product_pricing_active = get_post_meta($this->id, '_per_product_pricing_active', true) === 'yes' ? true : false;
     $this->per_product_shipping_active = get_post_meta($this->id, '_per_product_shipping_active', true) === 'yes' ? true : false;
     $this->base_price = ($base_price = get_post_meta($this->id, '_base_price', true)) ? $base_price : '';
     $this->base_regular_price = ($base_regular_price = get_post_meta($this->id, '_base_regular_price', true)) ? $base_regular_price : '';
     $this->base_sale_price = ($base_sale_price = get_post_meta($this->id, '_base_sale_price', true)) ? $base_sale_price : '';
     // NYP.
     if (WC_PB()->compatibility->is_nyp($this)) {
         $this->is_nyp = true;
     }
     $this->is_synced = false;
 }
 /**
  * __construct function.
  *
  * @access public
  * @param mixed $product
  * 
  */
 public function __construct($product)
 {
     global $sitepress;
     date_default_timezone_set("UTC");
     $this->product_type = 'auction';
     $this->auction_item_condition_array = apply_filters('simple_auction_item_condition', array('new' => __('New', 'wc_simple_auctions'), 'used' => __('Used', 'wc_simple_auctions')));
     parent::__construct($product);
     $this->is_closed();
     $this->is_started();
 }
 /**
  * __construct function.
  *
  * @access public
  * @param mixed $product
  */
 public function __construct($product = array())
 {
     $this->virtual = 'yes';
     $this->downloadable = 'yes';
     $this->manage_stock = 'yes';
     $this->product_type = 'ticket';
     add_filter('woocommerce_product_data_tabs', array($this, 'remove_tabs'), 10, 1);
     add_filter('product_type_options', array($this, 'add_virtual'), 10, 1);
     $getdir = '';
     parent::__construct($product);
 }
 /**
  * __construct function.
  *
  * @access public
  * @param mixed $product
  */
 public function __construct($product)
 {
     $this->product_type = 'amazon_listing';
     $this->id = 0;
     $this->asin = $product;
     $this->sku = $product;
     // this will show the ASIN on the generated email
     $this->post = new stdClass();
     // prevent non-object warning in /woocommerce/includes/abstracts/abstract-wc-product.php:693
     $this->post->post_status = 'publish';
     // make product purchasable for WooCommerce (?)
     parent::__construct($product);
     // parent::__construct( 0 );
 }
 /**
  * Initialize a gift card product.
  *
  * @param mixed $product
  */
 public function __construct($product)
 {
     $this->product_type = 'gift-card';
     $this->virtual = true;
     parent::__construct($product);
     global $GIFTS;
     /** @var YWGC_Gift_Cards $GIFTS */
     $this->amounts = $GIFTS->get_gift_card_product_amounts($this->id);
     $this->amounts_count = count($this->amounts);
     if ($count = count($this->amounts)) {
         $this->min_price = $this->amounts[0];
         $this->max_price = $this->amounts[$count - 1];
     }
 }
 /**
      27:      * Constructor
      28:      *
      29:      * @param mixed $product
      30:      */
 public function __construct($product)
 {
     $this->product_type = 'soya_variable';
     parent::__construct($product);
     //grap and assign product features ID
     $this->_features_id = get_post_meta($product->ID, '_soya_features', true);
     // get all features assigned to product features
     $features = new Soya_feature($this->_features_id);
     //make sure all features are updated
     //  parent::$all_features->update_feature_meta(64, 1);
     //set total features price
     $features->set_total_features_price();
     $this->set_regular_price();
     $this->all_features = $features;
     //add_filter('woocommerce_get_regular_price', array($this, 'set_regular_price'));
 }
 public function __construct($bundle_id)
 {
     $this->product_type = 'composite';
     parent::__construct($bundle_id);
     $this->composite_data = get_post_meta($this->id, '_bto_data', true);
     $this->per_product_pricing = get_post_meta($this->id, '_per_product_pricing_bto', true);
     $this->per_product_shipping = get_post_meta($this->id, '_per_product_shipping_bto', true);
     $this->composite_layout = get_post_meta($this->id, '_bto_style', true);
     $this->selections_style = get_post_meta($this->id, '_bto_selection_mode', true);
     $this->contains_nyp = false;
     $this->has_discounts = false;
     $this->base_price = ($base_price = get_post_meta($this->id, '_base_price', true)) ? $base_price : '';
     $this->base_regular_price = ($base_regular_price = get_post_meta($this->id, '_base_regular_price', true)) ? $base_regular_price : '';
     $this->base_sale_price = ($base_sale_price = get_post_meta($this->id, '_base_sale_price', true)) ? $base_sale_price : '';
     $this->hide_price_html = get_post_meta($this->id, '_bto_hide_shop_price', true) === 'yes' ? true : false;
 }
Example #9
0
 function __construct($bundle)
 {
     global $woocommerce_bundles;
     $this->product_type = 'bundle';
     parent::__construct($bundle);
     $this->bundle_data = get_post_meta($this->id, '_bundle_data', true);
     $bundled_item_ids = get_post_meta($this->id, '_bundled_ids', true);
     // Update from 3.X
     if (empty($this->bundle_data) && !empty($bundled_item_ids)) {
         $this->bundle_data = $woocommerce_bundles->helpers->serialize_bundle_meta($this->id);
     }
     $this->contains_nyp = false;
     $this->is_nyp = false;
     $this->contains_sub = false;
     $this->contains_optional = false;
     $this->contains_min_max_quantities = false;
     $this->on_sale = false;
     $this->has_item_with_variables = false;
     $this->all_items_visible = true;
     $this->all_items_sold_individually = true;
     $this->all_items_in_stock = true;
     $this->all_items_purchasable = true;
     $this->has_items_on_backorder = false;
     $this->per_product_pricing_active = get_post_meta($this->id, '_per_product_pricing_active', true) == 'yes' ? true : false;
     $this->per_product_shipping_active = get_post_meta($this->id, '_per_product_shipping_active', true) == 'yes' ? true : false;
     $this->min_price = get_post_meta($this->id, '_min_bundle_price', true);
     $this->max_price = get_post_meta($this->id, '_max_bundle_price', true);
     if ($this->is_priced_per_product()) {
         $this->price = 0;
     }
     // NYP
     if ($woocommerce_bundles->compatibility->is_nyp($this)) {
         $this->is_nyp = true;
     }
     $this->is_synced = false;
 }
 /**
  * Merges grouped product data into the parent object.
  * @param int|WC_Product|object $product Product to init.
  */
 public function __construct($product = 0)
 {
     $this->data = array_merge($this->data, $this->extra_data);
     parent::__construct($product);
 }
 /**
  * __construct function.
  *
  * @access public
  * @param mixed $product
  */
 public function __construct($product)
 {
     $this->product_type = 'external';
     parent::__construct($product);
 }
 /**
  * Constructor
  */
 public function __construct($product)
 {
     $this->product_type = 'resume_package';
     parent::__construct($product);
 }
 public function __construct($product)
 {
     $this->product_type = 'woo_auction';
     parent::__construct($product);
     // add additional functions here
 }
 function __construct($bundle_id)
 {
     global $woocommerce_bundles;
     $this->product_type = 'bundle';
     parent::__construct($bundle_id);
     if ($woocommerce_bundles->is_wc_v2()) {
         $this->is_wc_v2 = true;
     }
     $this->bundled_item_ids = get_post_meta($this->id, '_bundled_ids', true);
     $this->has_filters = false;
     $this->has_overrides = false;
     $this->sold_individually = true;
     if ($this->bundled_item_ids) {
         foreach ($this->bundled_item_ids as $bundled_id) {
             // Store 'variation filtering' boolean variables
             if (get_post_meta($this->id, 'filter_variations_' . $bundled_id, 'true') == 'yes') {
                 $this->variation_filters_active[$bundled_id] = true;
                 $this->has_filters = true;
             } else {
                 $this->variation_filters_active[$bundled_id] = false;
             }
             // Store 'override defaults' boolean variables
             if (get_post_meta($this->id, 'override_defaults_' . $bundled_id, 'true') == 'yes') {
                 $this->bundle_defaults_active[$bundled_id] = true;
                 $this->has_overrides = true;
             } else {
                 $this->bundle_defaults_active[$bundled_id] = false;
             }
             // Store bundled item quantities
             $this->bundled_item_quantities[$bundled_id] = get_post_meta($this->id, 'bundle_quantity_' . $bundled_id, 'true');
         }
     }
     if ($this->has_filters) {
         $this->allowed_variations = maybe_unserialize(get_post_meta($this->id, '_allowed_variations', true));
         // create array of attributes based on active variations
         foreach ($this->allowed_variations as $item_id => $allowed_variations) {
             if (!$this->variation_filters_active[$item_id]) {
                 continue;
             }
             $sep = explode('_', $item_id);
             $product_id = $sep[0];
             $attributes = (array) maybe_unserialize(get_post_meta($product_id, '_product_attributes', true));
             // filtered variation attributes (stores attributes of active variations)
             $filtered_attributes = array();
             $this->filtered_variation_attributes[$item_id] = array();
             // make array of active variation attributes
             foreach ($this->allowed_variations[$item_id] as $allowed_variation_id) {
                 // get variation meta of allowed variations
                 $product_custom_fields = get_post_custom($allowed_variation_id);
                 foreach ($product_custom_fields as $name => $value) {
                     if (!strstr($name, 'attribute_')) {
                         continue;
                     }
                     $attribute_name = substr($name, strlen('attribute_'));
                     if (!$value[0]) {
                         $description = 'Any';
                     } else {
                         $term = get_term_by('slug', $value[0], $attribute_name);
                         $description = $term == false ? '' : $term->name;
                     }
                     if (!$description) {
                         $description = $value[0];
                     }
                     if (!isset($filtered_attributes[$attribute_name])) {
                         $filtered_attributes[$attribute_name]['descriptions'][] = $description;
                         $filtered_attributes[$attribute_name]['slugs'][] = $value[0];
                     } elseif (!in_array($description, $filtered_attributes[$attribute_name])) {
                         $filtered_attributes[$attribute_name]['descriptions'][] = $description;
                         $filtered_attributes[$attribute_name]['slugs'][] = $value[0];
                     }
                 }
                 // clean up product attributes
                 foreach ($attributes as $attribute) {
                     if (!$attribute['is_variation']) {
                         continue;
                     }
                     $attribute_name = sanitize_title($attribute['name']);
                     if (array_key_exists($attribute_name, $filtered_attributes) && !in_array('Any', $filtered_attributes[$attribute_name]['descriptions'])) {
                         $this->filtered_variation_attributes[$item_id][$attribute_name] = $filtered_attributes[$attribute_name];
                     }
                 }
             }
         }
     }
     if ($this->has_overrides) {
         $this->bundle_defaults = get_post_meta($this->id, '_bundle_defaults', true);
     }
     $this->per_product_pricing_active = get_post_meta($this->id, '_per_product_pricing_active', true) == 'yes' ? true : false;
     if ($this->per_product_pricing_active) {
         $this->price = 0;
     }
     $this->per_product_shipping_active = get_post_meta($this->id, '_per_product_shipping_active', true) == 'yes' ? true : false;
     if ($this->bundled_item_ids) {
         $this->load_bundle_data();
         $this->availability = $this->bundle_availability();
     }
 }
 function __construct($product, $arg = array())
 {
     $this->product_type = 'pack';
     parent::__construct($product);
 }
Example #16
0
 public function __construct($id)
 {
     _deprecated_function('woocommerce_product', '1.4', 'WC_Product()');
     parent::__construct($id);
 }
 public function __construct($product)
 {
     $this->product_type = 'dln_fashion';
     parent::__construct($product);
 }
 /**
  * __construct function.
  *
  * @access public
  * @param mixed $product
  */
 public function __construct($product)
 {
     $this->product_type = 'points';
     parent::__construct($product);
 }
 /**
  * __construct function.
  *
  * @access public
  * @param mixed $product
  */
 public function __construct($product)
 {
     $this->product_type = 'grouped';
     parent::__construct($product);
 }
 /**
  * Constructor
  */
 public function __construct($product)
 {
     $this->product_type = 'booking';
     parent::__construct($product);
 }
 /**
  * Initialize simple product.
  *
  * @param mixed $product
  */
 public function __construct($product = 0)
 {
     $this->supports[] = 'ajax_add_to_cart';
     parent::__construct($product);
 }
 /**
  * Initialize simple product.
  *
  * @param mixed $product
  */
 public function __construct($product)
 {
     $this->product_type = 'simple';
     $this->supports[] = 'ajax_add_to_cart';
     parent::__construct($product);
 }
 /**
  * __construct function.
  *
  * @access public
  * @param mixed $product
  */
 public function __construct($product)
 {
     $this->product_type = 'variable';
     parent::__construct($product);
 }
 public function __construct($product)
 {
     $this->product_type = 'trip';
     $this->manage_stock = 'yes';
     parent::__construct($product);
 }