get_type() public method

Get internal type. Should return string and *should be overridden* by child classes.
Since: 2.7.0
public get_type ( ) : string
return string
 /**
  * Get standard product data that applies to every product type
  *
  * @since 2.1
  * @param WC_Product $product
  * @return array
  */
 private function get_product_data($product)
 {
     return array('title' => $product->get_name(), 'id' => $product->get_id(), 'created_at' => $this->server->format_datetime($product->get_date_created(), false, true), 'updated_at' => $this->server->format_datetime($product->get_date_modified(), false, true), 'type' => $product->get_type(), 'status' => $product->get_status(), 'downloadable' => $product->is_downloadable(), 'virtual' => $product->is_virtual(), 'permalink' => $product->get_permalink(), 'sku' => $product->get_sku(), 'price' => wc_format_decimal($product->get_price(), 2), 'regular_price' => wc_format_decimal($product->get_regular_price(), 2), 'sale_price' => $product->get_sale_price() ? wc_format_decimal($product->get_sale_price(), 2) : null, 'price_html' => $product->get_price_html(), 'taxable' => $product->is_taxable(), 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'managing_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'purchaseable' => $product->is_purchasable(), 'featured' => $product->is_featured(), 'visible' => $product->is_visible(), 'catalog_visibility' => $product->get_catalog_visibility(), 'on_sale' => $product->is_on_sale(), 'weight' => $product->get_weight() ? wc_format_decimal($product->get_weight(), 2) : null, 'dimensions' => array('length' => $product->get_length(), 'width' => $product->get_width(), 'height' => $product->get_height(), 'unit' => get_option('woocommerce_dimension_unit')), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null, 'description' => apply_filters('the_content', $product->get_description()), 'short_description' => apply_filters('woocommerce_short_description', $product->get_short_description()), 'reviews_allowed' => $product->get_reviews_allowed(), 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => $product->get_rating_count(), 'related_ids' => array_map('absint', array_values(wc_get_related_products($product->get_id()))), 'upsell_ids' => array_map('absint', $product->get_upsell_ids()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sell_ids()), 'categories' => wc_get_object_terms($product->get_id(), 'product_cat', 'name'), 'tags' => wc_get_object_terms($product->get_id(), 'product_tag', 'name'), 'images' => $this->get_images($product), 'featured_src' => wp_get_attachment_url(get_post_thumbnail_id($product->get_id())), 'attributes' => $this->get_attributes($product), 'downloads' => $this->get_downloads($product), 'download_limit' => $product->get_download_limit(), 'download_expiry' => $product->get_download_expiry(), 'download_type' => 'standard', 'purchase_note' => apply_filters('the_content', $product->get_purchase_note()), 'total_sales' => $product->get_total_sales(), 'variations' => array(), 'parent' => array());
 }
 /**
  * Get product data.
  *
  * @param WC_Product $product Product instance.
  * @return array
  */
 protected function get_product_data($product)
 {
     $data = array('id' => $product->get_id(), 'name' => $product->get_name(), 'slug' => $product->get_slug(), 'permalink' => $product->get_permalink(), 'date_created' => wc_rest_prepare_date_response($product->get_date_created()), 'date_modified' => wc_rest_prepare_date_response($product->get_date_modified()), 'type' => $product->get_type(), 'status' => $product->get_status(), 'featured' => $product->is_featured(), 'catalog_visibility' => $product->get_catalog_visibility(), 'description' => wpautop(do_shortcode($product->get_description())), 'short_description' => apply_filters('woocommerce_short_description', $product->get_short_description()), 'sku' => $product->get_sku(), 'price' => $product->get_price(), 'regular_price' => $product->get_regular_price(), 'sale_price' => $product->get_sale_price() ? $product->get_sale_price() : '', 'date_on_sale_from' => $product->get_date_on_sale_from() ? date('Y-m-d', $product->get_date_on_sale_from()) : '', 'date_on_sale_to' => $product->get_date_on_sale_to() ? date('Y-m-d', $product->get_date_on_sale_to()) : '', 'price_html' => $product->get_price_html(), 'on_sale' => $product->is_on_sale(), 'purchasable' => $product->is_purchasable(), 'total_sales' => $product->get_total_sales(), 'virtual' => $product->is_virtual(), 'downloadable' => $product->is_downloadable(), 'downloads' => $this->get_downloads($product), 'download_limit' => $product->get_download_limit(), 'download_expiry' => $product->get_download_expiry(), 'download_type' => 'standard', 'external_url' => $product->is_type('external') ? $product->get_product_url() : '', 'button_text' => $product->is_type('external') ? $product->get_button_text() : '', 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'manage_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders' => $product->get_backorders(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'weight' => $product->get_weight(), 'dimensions' => array('length' => $product->get_length(), 'width' => $product->get_width(), 'height' => $product->get_height()), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => $product->get_shipping_class_id(), 'reviews_allowed' => $product->get_reviews_allowed(), 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => $product->get_rating_count(), 'related_ids' => array_map('absint', array_values(wc_get_related_products($product->get_id()))), 'upsell_ids' => array_map('absint', $product->get_upsell_ids()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sell_ids()), 'parent_id' => $product->get_parent_id(), 'purchase_note' => wpautop(do_shortcode(wp_kses_post($product->get_purchase_note()))), 'categories' => $this->get_taxonomy_terms($product), 'tags' => $this->get_taxonomy_terms($product, 'tag'), 'images' => $this->get_images($product), 'attributes' => $this->get_attributes($product), 'default_attributes' => $this->get_default_attributes($product), 'variations' => array(), 'grouped_products' => array(), 'menu_order' => $product->get_menu_order());
     return $data;
 }
 /**
  * Quick edit.
  *
  * @param integer    $post_id
  * @param WC_Product $product
  */
 private function quick_edit_save($post_id, $product)
 {
     $data_store = $product->get_data_store();
     $old_regular_price = $product->get_regular_price();
     $old_sale_price = $product->get_sale_price();
     // Save fields
     if (isset($_REQUEST['_sku'])) {
         $sku = $product->get_sku();
         $new_sku = (string) wc_clean($_REQUEST['_sku']);
         if ($new_sku !== $sku) {
             if (!empty($new_sku)) {
                 $unique_sku = wc_product_has_unique_sku($post_id, $new_sku);
                 if ($unique_sku) {
                     $product->set_sku($new_sku);
                 }
             } else {
                 $product->set_sku('');
             }
         }
     }
     if (isset($_REQUEST['_weight'])) {
         $product->set_weight(wc_clean($_REQUEST['_weight']));
     }
     if (isset($_REQUEST['_length'])) {
         $product->set_length(wc_clean($_REQUEST['_length']));
     }
     if (isset($_REQUEST['_width'])) {
         $product->set_width(wc_clean($_REQUEST['_width']));
     }
     if (isset($_REQUEST['_height'])) {
         $product->set_height(wc_clean($_REQUEST['_height']));
     }
     if (!empty($_REQUEST['_shipping_class'])) {
         $shipping_class = '_no_shipping_class' == $_REQUEST['_shipping_class'] ? '' : wc_clean($_REQUEST['_shipping_class']);
         $shipping_class_id = $data_store->get_shipping_class_id_by_slug($shipping_class);
         if ($shipping_class_id) {
             $product->set_shipping_class_id($shipping_class_id);
         }
     }
     if (isset($_REQUEST['_visibility'])) {
         $product->set_catalog_visibility(wc_clean($_REQUEST['_visibility']));
     }
     if (isset($_REQUEST['_featured'])) {
         $product->set_featured(true);
     } else {
         $product->set_featured(false);
     }
     if (isset($_REQUEST['_tax_status'])) {
         $product->set_tax_status(wc_clean($_REQUEST['_tax_status']));
     }
     if (isset($_REQUEST['_tax_class'])) {
         $product->set_tax_class(wc_clean($_REQUEST['_tax_class']));
     }
     if ($product->is_type('simple') || $product->is_type('external')) {
         if (isset($_REQUEST['_regular_price'])) {
             $new_regular_price = '' === $_REQUEST['_regular_price'] ? '' : wc_format_decimal($_REQUEST['_regular_price']);
             $product->set_regular_price($new_regular_price);
         } else {
             $new_regular_price = null;
         }
         if (isset($_REQUEST['_sale_price'])) {
             $new_sale_price = '' === $_REQUEST['_sale_price'] ? '' : wc_format_decimal($_REQUEST['_sale_price']);
             $product->set_sale_price($new_sale_price);
         } else {
             $new_sale_price = null;
         }
         // Handle price - remove dates and set to lowest
         $price_changed = false;
         if (!is_null($new_regular_price) && $new_regular_price != $old_regular_price) {
             $price_changed = true;
         } elseif (!is_null($new_sale_price) && $new_sale_price != $old_sale_price) {
             $price_changed = true;
         }
         if ($price_changed) {
             $product->set_date_on_sale_to('');
             $product->set_date_on_sale_from('');
         }
     }
     // Handle Stock Data
     $manage_stock = !empty($_REQUEST['_manage_stock']) && 'grouped' !== $product->get_type() ? 'yes' : 'no';
     $backorders = !empty($_REQUEST['_backorders']) ? wc_clean($_REQUEST['_backorders']) : 'no';
     $stock_status = !empty($_REQUEST['_stock_status']) ? wc_clean($_REQUEST['_stock_status']) : 'instock';
     $stock_amount = 'yes' === $manage_stock ? wc_stock_amount($_REQUEST['_stock']) : '';
     if ('yes' === get_option('woocommerce_manage_stock')) {
         // Apply product type constraints to stock status
         if ($product->is_type('external')) {
             // External always in stock
             $stock_status = 'instock';
         } elseif ($product->is_type('variable')) {
             // Stock status is always determined by children
             foreach ($product->get_children() as $child_id) {
                 $child = wc_get_product($child_id);
                 if (!$product->get_manage_stock()) {
                     $child->set_stock_status($stock_status);
                     $child->save();
                 }
             }
             $product = WC_Product_Variable::sync($product, false);
         }
         $product->set_manage_stock($manage_stock);
         $product->set_backorders($backorders);
         $product->save();
         if (!$product->is_type('variable')) {
             wc_update_product_stock_status($post_id, $stock_status);
         }
         wc_update_product_stock($post_id, $stock_amount);
     } else {
         $product->save();
         wc_update_product_stock_status($post_id, $stock_status);
     }
     do_action('woocommerce_product_quick_edit_save', $product);
 }