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

Add to cart form: Fix fatal error when missing product param in add_to_cart_redirect_filter #10316

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/BlockTypes/AddToCartForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AddToCartForm extends AbstractBlock {
protected function initialize() {
parent::initialize();
add_filter( 'wc_add_to_cart_message_html', array( $this, 'add_to_cart_message_html_filter' ), 10, 2 );
add_filter( 'woocommerce_add_to_cart_redirect', array( $this, 'add_to_cart_redirect_filter' ), 10, 2 );
add_filter( 'woocommerce_add_to_cart_redirect', array( $this, 'add_to_cart_redirect_filter' ), 10, 1 );
}

/**
Expand Down Expand Up @@ -157,10 +157,9 @@ public function add_to_cart_message_html_filter( $message ) {
* is clicked.
*
* @param string $url The URL to redirect to after the product is added to the cart.
* @param object $product The product being added to the cart.
* @return string The filtered redirect URL.
*/
public function add_to_cart_redirect_filter( $url, $product ) {
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'] ) {
return wp_validate_redirect( wp_get_referer(), $url );
Expand Down
Loading