Skip to content

Commit 5c10494

Browse files
authored
Merge pull request #182 from kimcoleman/fix-wc-checkout-hide-banner
Adjusting logic so the entire checkout process in WC can hide the banner, if desired.
2 parents ae1adfa + 8391bb0 commit 5c10494

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

modules/ecommerce/wc/class-swsales-module-wc.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,34 @@ public static function create_coupon_ajax() {
253253
} // end create_discount_code_ajax()
254254

255255
/**
256-
* Returns whether the current page is the landing page
257-
* for the passed Sitewide Sale.
256+
* Returns whether the current page is the the checkout, cart or confirmation page.
258257
*
259258
* @param boolean $is_checkout_page current value from filter.
260259
* @param SWSales_Sitewide_Sale $sitewide_sale being checked.
261-
* @return boolean
260+
* @return boolean $is_checkout_page true if we are on the checkout, cart, or confirmation page, false otherwise.
262261
*/
263262
public static function is_checkout_page( $is_checkout_page, $sitewide_sale ) {
264263
if ( 'wc' !== $sitewide_sale->get_sale_type() ) {
265264
return $is_checkout_page;
266265
}
267-
return ( ! empty( wc_get_page_id( 'cart' ) ) && is_page( wc_get_page_id( 'cart' ) ) ) ? true : $is_checkout_page;
266+
267+
// Check for cart page.
268+
$is_cart_page = wc_get_page_id( 'cart' );
269+
if ( ! empty( $is_cart_page ) && is_page( $is_cart_page ) ) {
270+
return true;
271+
}
272+
273+
// Check for checkout page.
274+
if ( function_exists( 'is_checkout' ) && is_checkout() ) {
275+
return true;
276+
}
277+
278+
// Check for order confirmation/thank you page.
279+
if ( is_wc_endpoint_url( 'order-received' ) ) {
280+
return true;
281+
}
282+
283+
return $is_checkout_page;
268284
}
269285

270286
/**

0 commit comments

Comments
 (0)