Preview checkout without dummy product

This commit is contained in:
Mike Jolley 2018-05-22 11:19:09 +01:00
parent 0d799b2d06
commit be63fb152a
3 changed files with 2 additions and 28 deletions

View File

@ -274,7 +274,7 @@ class WC_AJAX {
wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true );
if ( WC()->cart->is_empty() ) {
if ( WC()->cart->is_empty() && ! is_customize_preview() ) {
self::update_order_review_expired();
}

View File

@ -21,7 +21,6 @@ class WC_Shop_Customizer {
add_action( 'customize_controls_print_styles', array( $this, 'add_styles' ) );
add_action( 'customize_controls_print_scripts', array( $this, 'add_scripts' ), 30 );
add_action( 'wp_enqueue_scripts', array( $this, 'add_frontend_scripts' ) );
add_action( 'woocommerce_cart_loaded_from_session', array( $this, 'populate_cart' ) );
}
/**
@ -55,31 +54,6 @@ class WC_Shop_Customizer {
wp_add_inline_style( 'customize-preview', $css );
}
/**
* Make sure the cart has something inside when we're customizing.
*
* @return void
*/
public function populate_cart() {
if ( ! is_customize_preview() ) {
return;
}
if ( WC()->cart->is_empty() ) {
$dummy_product = new WC_Product();
$dummy_product->set_name( 'Sample' );
$dummy_product->set_price( 0 );
$dummy_product->set_status( 'publish' );
$cart_contents['customize-preview'] = array(
'data' => $dummy_product,
'product_id' => 0,
'variation_id' => 0,
'data_hash' => false,
'quantity' => 1,
);
WC()->cart->set_cart_contents( $cart_contents );
}
}
/**
* CSS styles to improve our form.
*/

View File

@ -222,7 +222,7 @@ class WC_Shortcode_Checkout {
wc_print_notices();
// Check cart has contents.
if ( WC()->cart->is_empty() ) {
if ( WC()->cart->is_empty() && ! is_customize_preview() ) {
return;
}