[英]Woocommerce product page redirect breaks add to cart button
To be able to add content to the product page I created a page for each product and displayed them with the shortcode [product_page id="20"]
.为了能够向产品页面添加内容,我为每个产品创建了一个页面并使用简码
[product_page id="20"]
显示它们。
My own product page url is online-shop.de/my-product-1/
我自己的产品页面 url 是
online-shop.de/my-product-1/
The product page of woocommerce is online-shop.de/product/my-product-1/
woocommerce的产品页面是
online-shop.de/product/my-product-1/
So to always keep the user on my editable product page I have a redirect which redirects /product/my-product-1/
to /my-product-1/
but my problem now is because of the redirect I can't add the product to the shopping cart anymore.因此,为了始终将用户留在我的可编辑产品页面上,我有一个重定向,将
/product/my-product-1/
重定向到/my-product-1/
但我现在的问题是由于重定向我无法添加产品购物车了。 How can I fix this?我怎样才能解决这个问题?
Solution was to use the wp_safe_redirect()
function of wordpress instead of a permanent 303 redirect (with WP Plugin called Redirects).解决方案是使用 wordpress 的
wp_safe_redirect()
function 而不是永久的 303 重定向(使用名为 Redirects 的 WP 插件)。 To do this i build the new url by getting the product url and building it again without the "product" directory and use it as parameter in the wp function wp_safe_redirect($newUrl)
为此,我通过获取产品 url 构建新的 url 并在没有“产品”目录的情况下再次构建它,并将其用作 wp
wp_safe_redirect($newUrl)
中的参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.