diff --git a/src/BlockTypes/AddToCartForm.php b/src/BlockTypes/AddToCartForm.php index 853a037607a..0d5b0782796 100644 --- a/src/BlockTypes/AddToCartForm.php +++ b/src/BlockTypes/AddToCartForm.php @@ -162,6 +162,11 @@ public function add_to_cart_message_html_filter( $message ) { public function add_to_cart_redirect_filter( $url ) { // phpcs:ignore if ( isset( $_POST['is-descendent-of-single-product-block'] ) && 'true' == $_POST['is-descendent-of-single-product-block'] ) { + + if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) { + return wc_get_cart_url(); + } + return wp_validate_redirect( wp_get_referer(), $url ); }