Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Make block to respect the Redirect to Cart setting (#11151)
Browse files Browse the repository at this point in the history
  • Loading branch information
thealexandrelara authored Oct 9, 2023
1 parent e8d97cf commit 9e0da1c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/BlockTypes/AddToCartForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down

0 comments on commit 9e0da1c

Please sign in to comment.