| 1 |
<?php namespace TierPricingTable\Addons\LayoutConfigurator; |
| 2 |
|
| 3 |
use WC_Product_Simple; |
| 4 |
|
| 5 |
/** |
| 6 |
* In-memory product for the layout preview: a fixed price and no database row. Registered with |
| 7 |
* WooCommerce's product factory for its id (see LayoutPreview::getProduct()), so wc_get_product() calls |
| 8 |
* inside the renderer resolve to it as well. |
| 9 |
*/ |
| 10 |
class PreviewProduct extends WC_Product_Simple { |
| 11 |
|
| 12 |
/** |
| 13 |
* Id no stored product uses. |
| 14 |
*/ |
| 15 |
const ID = 2000000000; |
| 16 |
|
| 17 |
public function __construct( $product = 0 ) { |
| 18 |
parent::__construct( 0 ); // no data store read |
| 19 |
|
| 20 |
$this->set_id( self::ID ); |
| 21 |
$this->set_props( array( |
| 22 |
'name' => __( 'Preview product', 'tier-pricing-table' ), |
| 23 |
'status' => 'publish', |
| 24 |
'catalog_visibility' => 'visible', |
| 25 |
'regular_price' => (string) LayoutPreview::PRICE, |
| 26 |
'price' => (string) LayoutPreview::PRICE, |
| 27 |
'stock_status' => 'instock', |
| 28 |
) ); |
| 29 |
$this->set_object_read( true ); |
| 30 |
} |
| 31 |
} |
| 32 |
|