From cbf373ab3c53b9b3c2e8fdd71134a7fa25677d96 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 16 Jul 2015 17:06:12 +0100 Subject: [PATCH 1/3] kses store notice --- includes/wc-template-functions.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 6c4542a8161..b13021a2216 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -423,14 +423,17 @@ if ( ! function_exists( 'woocommerce_demo_store' ) ) { * */ function woocommerce_demo_store() { - if ( !is_store_notice_showing() ) + if ( ! is_store_notice_showing() ) { return; + } $notice = get_option( 'woocommerce_demo_store_notice' ); - if ( empty( $notice ) ) + + if ( empty( $notice ) ) { $notice = __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' ); + } - echo apply_filters( 'woocommerce_demo_store', '

' . $notice . '

' ); + echo apply_filters( 'woocommerce_demo_store', '

' . wp_kses_post( $notice ) . '

' ); } } From 3e8228161db00027a6a72f8fa7b62d5296e8cc8f Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 16 Jul 2015 17:32:31 +0100 Subject: [PATCH 2/3] Load session during cron, but not other frontend classes Closes #7183 @claudiosmweb --- woocommerce.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/woocommerce.php b/woocommerce.php index 874f1847c27..425611d8ca3 100644 --- a/woocommerce.php +++ b/woocommerce.php @@ -218,6 +218,11 @@ final class WooCommerce { $this->frontend_includes(); } + if ( $this->is_request( 'frontend' ) || $this->is_request( 'cron' ) ) { + include_once( 'includes/abstracts/abstract-wc-session.php' ); + include_once( 'includes/class-wc-session-handler.php' ); + } + if ( $this->is_request( 'cron' ) && 'yes' === get_option( 'woocommerce_allow_tracking', 'no' ) ) { include_once( 'includes/class-wc-tracker.php' ); } @@ -225,7 +230,7 @@ final class WooCommerce { $this->query = include( 'includes/class-wc-query.php' ); // The main query class $this->api = include( 'includes/class-wc-api.php' ); // API Class - include_once( 'includes/class-wc-auth.php' ); // Auth Class + include_once( 'includes/class-wc-auth.php' ); // Auth Class include_once( 'includes/class-wc-post-types.php' ); // Registers post types include_once( 'includes/abstracts/abstract-wc-product.php' ); // Products include_once( 'includes/abstracts/abstract-wc-order.php' ); // Orders @@ -246,8 +251,6 @@ final class WooCommerce { public function frontend_includes() { include_once( 'includes/wc-cart-functions.php' ); include_once( 'includes/wc-notice-functions.php' ); - include_once( 'includes/abstracts/abstract-wc-session.php' ); - include_once( 'includes/class-wc-session-handler.php' ); include_once( 'includes/wc-template-hooks.php' ); include_once( 'includes/class-wc-template-loader.php' ); // Template Loader include_once( 'includes/class-wc-frontend-scripts.php' ); // Frontend Scripts @@ -282,13 +285,14 @@ final class WooCommerce { $this->countries = new WC_Countries(); // Countries class $this->integrations = new WC_Integrations(); // Integrations class + // Session class, handles session data for users - can be overwritten if custom handler is needed + if ( $this->is_request( 'frontend' ) || $this->is_request( 'cron' ) ) { + $session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' ); + $this->session = new $session_class(); + } + // Classes/actions loaded for the frontend and for ajax requests if ( $this->is_request( 'frontend' ) ) { - // Session class, handles session data for users - can be overwritten if custom handler is needed - $session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' ); - - // Class instances - $this->session = new $session_class(); $this->cart = new WC_Cart(); // Cart class, stores the cart contents $this->customer = new WC_Customer(); // Customer class, handles data such as customer location } From d1db647c05037c061fb46294a39d874ff95fafbd Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 16 Jul 2015 17:53:52 +0100 Subject: [PATCH 3/3] Fix validate_sale_items logic for variable products Closes #8591 --- includes/class-wc-coupon.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-coupon.php b/includes/class-wc-coupon.php index 57551b517a2..7c9ace513c6 100644 --- a/includes/class-wc-coupon.php +++ b/includes/class-wc-coupon.php @@ -401,10 +401,14 @@ class WC_Coupon { if ( 'yes' === $this->exclude_sale_items && $this->is_type( array( 'fixed_product', 'percent_product' ) ) ) { $valid_for_cart = false; $product_ids_on_sale = wc_get_product_ids_on_sale(); + if ( ! WC()->cart->is_empty() ) { foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { - if ( sizeof( array_intersect( array( absint( $cart_item['product_id'] ), absint( $cart_item['variation_id'] ), $cart_item['data']->get_parent() ), $product_ids_on_sale ) ) === 0 ) { - // not on sale + if ( ! empty( $cart_item['variation_id'] ) ) { + if ( ! in_array( $cart_item['variation_id'], $product_ids_on_sale, true ) ) { + $valid_for_cart = true; + } + } elseif ( ! in_array( $cart_item['product_id'], $product_ids_on_sale, true ) ) { $valid_for_cart = true; } }