data = array(
'name' => esc_html( 'Product name', 'et_builder' ),
'slug' => 'product-name',
'date_created' => current_time( 'timestamp' ),
'date_modified' => null,
'status' => 'publish',
'featured' => false,
'catalog_visibility' => 'visible',
'description' => esc_html( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris bibendum eget dui sed vehicula. Suspendisse potenti. Nam dignissim at elit non lobortis. Cras sagittis dui diam, a finibus nibh euismod vestibulum. Integer sed blandit felis. Maecenas commodo ante in mi ultricies euismod. Morbi condimentum interdum luctus. Mauris iaculis interdum risus in volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent cursus odio eget cursus pharetra. Aliquam lacinia lectus a nibh ullamcorper maximus. Quisque at sapien pulvinar, dictum elit a, bibendum massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris non pellentesque urna.', 'et_builder' ),
'short_description' => esc_html( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris bibendum eget dui sed vehicula. Suspendisse potenti. Nam dignissim at elit non lobortis.', 'et_builder' ),
'sku' => 'product-name',
'price' => '75',
'regular_price' => '80',
'sale_price' => '65',
'date_on_sale_from' => null,
'date_on_sale_to' => null,
'total_sales' => '0',
'tax_status' => 'taxable',
'tax_class' => '',
'manage_stock' => true,
'stock_quantity' => 50,
'stock_status' => 'instock',
'backorders' => 'no',
'low_stock_amount' => 2,
'sold_individually' => false,
'weight' => 2,
'length' => '',
'width' => 2,
'height' => 2,
'upsell_ids' => array(),
'cross_sell_ids' => array(),
'parent_id' => 0,
'reviews_allowed' => true,
'purchase_note' => '',
'attributes' => array(),
'default_attributes' => array(),
'menu_order' => 0,
'post_password' => '',
'virtual' => false,
'downloadable' => false,
'category_ids' => array(),
'tag_ids' => array(),
'shipping_class_id' => 0,
'downloads' => array(),
'image_id' => '',
'gallery_image_ids' => array(),
'download_limit' => -1,
'download_expiry' => -1,
'rating_counts' => array(
4 => 2,
),
'average_rating' => '4.00',
'review_count' => 2,
'recent_product_ids' => null,
);
parent::__construct( $product );
}
/**
* Get internal type.
* Define custom internal type so custom data store can be used to bypass database value retrieval
*
* @since 4.0.10
*
* @return string
*/
public function get_type() {
return 'tb-placeholder';
}
/**
* Get placeholder product as available variation. The method is basically identical to
* `WC_Product_Variable->get_available_variation()` except for the checks which are removed
* so placeholder value can be passed
*
* @since 4.3.3
*
* @param int|object $variation not needed since it will be overwritten by placeholder variation
* but it needs to be kept for compatibility with base class' method
*
* @return array
*/
function get_available_variation( $variation = 0 ) {
$variation = new ET_Theme_Builder_Woocommerce_Product_Variation_Placeholder();
$show_variation_price = apply_filters( 'woocommerce_show_variation_price', $variation->get_price() === '' || $this->get_variation_sale_price( 'min' ) !== $this->get_variation_sale_price( 'max' ) || $this->get_variation_regular_price( 'min' ) !== $this->get_variation_regular_price( 'max' ), $this, $variation );
// Set variation id; Prevent $product->get_id() returns falsey which usually triggers wc_product_get()
// in WC add ons; Valid $product->get_id() makes global $product being used most of the time
$variation->set_id( $this->get_id() );
// Set current product id as variation parent id so $product->get_parent_id() returns
// valid value (mostly when being called by WC add-ons). The absence of this value (in TB)
// triggers new `wc_get_product()` which most likely returned unwanted output
$variation->set_prop( 'parent_id', $this->get_id() );
// Returned array properties are identical to `WC_Product_Variable->get_available_variation()`
return apply_filters(
'woocommerce_available_variation',
array(
'attributes' => $variation->get_variation_attributes(),
'availability_html' => wc_get_stock_html( $variation ),
'backorders_allowed' => $variation->backorders_allowed(),
'dimensions' => $variation->get_dimensions( false ),
'dimensions_html' => wc_format_dimensions( $variation->get_dimensions( false ) ),
'display_price' => wc_get_price_to_display( $variation ),
'display_regular_price' => wc_get_price_to_display( $variation, array( 'price' => $variation->get_regular_price() ) ),
'image' => wc_get_product_attachment_props( $variation->get_image_id() ),
'image_id' => $variation->get_image_id(),
'is_downloadable' => $variation->is_downloadable(),
'is_in_stock' => $variation->is_in_stock(),
'is_purchasable' => $variation->is_purchasable(),
'is_sold_individually' => $variation->is_sold_individually() ? 'yes' : 'no',
'is_virtual' => $variation->is_virtual(),
'max_qty' => 0 < $variation->get_max_purchase_quantity() ? $variation->get_max_purchase_quantity() : '',
'min_qty' => $variation->get_min_purchase_quantity(),
'price_html' => $show_variation_price ? '' . $variation->get_price_html() . '' : '',
'sku' => $variation->get_sku(),
'variation_description' => wc_format_content( $variation->get_description() ),
'variation_id' => $variation->get_id(),
'variation_is_active' => $variation->variation_is_active(),
'variation_is_visible' => $variation->variation_is_visible(),
'weight' => $variation->get_weight(),
'weight_html' => wc_format_weight( $variation->get_weight() ),
),
$this,
$variation
);
}
/**
* Add to cart's