[WooCommerce] Prevents products being added to cart
-
When a WooCommerce product is added to cart (POST) with the product URL being redirected from in the Redirection plugin, the product is not added to cart.
The POST request for adding the product to cart gets a 301 HTTP response instead.That to the old URL is posted the actual underlying issue – the
<form
action
URL still points to the old URL from which the Redirection plugin already redirected away to the new URL.
So why does the WooCommerce add to cart form still use the old URL inaction
?Edit: Things become more clear now – the template for the add to cart form uses the permalink of the product (post):
<form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
But the Redirection plugin doesn’t filter the product permalinks.
IMHO the best solution would be if the Redirection plugin could allow processing of those POST requests and then do nothing as these specific POST requests are invoked by ajax and not visible to the user.There is no filter for
is_protected_url
yet, so I can’t just add a hook to prevent redirection of WooCommerce POST requests.
- The topic ‘[WooCommerce] Prevents products being added to cart’ is closed to new replies.