简体   繁体   English

Woocommerce 产品页面重定向中断添加到购物车按钮

[英]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.

相关问题 如果产品在购物车中,则更改“添加到购物车”按钮文本,并在 WooCommerce 中满足条件时重定向到购物车页面 - Change "add to cart" button text if product is in cart and redirect to cart page when condition is met in WooCommerce woocommerce 添加到单个产品页面上的购物车按钮 - woocommerce add to cart button on single product page Woocommerce - 将商店页面上的“添加到购物车”重定向到产品页面? - Woocommerce - Redirect Add-to-Cart on Shop page to Product Page? 其他Woocommerce产品“添加到购物车”按钮,可重定向到结帐 - Additional Woocommerce product Add To Cart button that redirect to checkout Woocommerce使用链接,重定向和刷新购物车页面添加产品 - Woocommerce Add Product with Link, redirect and Refresh Cart Page 将添加到购物车按钮重定向到 WooCommerce 中 1 个特定登录页面的结帐页面 - Redirect add to cart button to checkout page for 1 specific landing page in WooCommerce WooCommerce隐藏循环和产品页面上的“添加到购物车”按钮 - WooCommerce Hide Add To Cart Button on Loop & Product Page 添加到购物车按钮在 Woocommerce 的单个产品页面上不起作用 - Add to cart button not working on single product page in Woocommerce 在单个产品页面/ Wordpress / Woocommerce中禁用Ajax添加到购物车按钮 - Disable ajax for add to cart button in single product page / Wordpress / Woocommerce Woocommerce - 产品页面 - 如何在“添加到购物车”按钮上创建 AJAX? - Woocommerce - Product Page - How to create AJAX on "Add To Cart" button?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM