![](/img/trans.png)
[英]Change "add to cart" button text if product is in cart and redirect to cart page when condition is met in WooCommerce
[英]Woocommerce product page redirect breaks add to cart button
為了能夠向產品頁面添加內容,我為每個產品創建了一個頁面並使用簡碼[product_page id="20"]
顯示它們。
我自己的產品頁面 url 是online-shop.de/my-product-1/
woocommerce的產品頁面是online-shop.de/product/my-product-1/
因此,為了始終將用戶留在我的可編輯產品頁面上,我有一個重定向,將/product/my-product-1/
重定向到/my-product-1/
但我現在的問題是由於重定向我無法添加產品購物車了。 我怎樣才能解決這個問題?
解決方案是使用 wordpress 的wp_safe_redirect()
function 而不是永久的 303 重定向(使用名為 Redirects 的 WP 插件)。 為此,我通過獲取產品 url 構建新的 url 並在沒有“產品”目錄的情況下再次構建它,並將其用作 wp wp_safe_redirect($newUrl)
中的參數
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.