簡體   English   中英

Woocommerce 滑動購物車 - 為每個產品添加刪除按鈕

[英]Woocommerce sliding cart - add remove button for each product

我使用 WooCommerce 購物車標簽。 可以為產品添加刪除按鈕嗎?

在此處輸入圖片說明

這很簡單:

導航到wp-content/plugins/woocommerce/templates/cart並打開mini-cart.php li標簽內,添加以下代碼:

<?php
    echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s">&times;</a>', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __( 'Remove this item', 'woocommerce' ) ), $cart_item_key );
?>

這將為滑動購物車中的每個產品添加一個刪除按鈕(X)。

這樣就完成了。

對於我來說,Daniel的解決方案不起作用,以下代碼可以完成工作:

echo apply_filters( 'woocommerce_cart_item_remove_link', 
sprintf( '<a href="%s" class="remove" title="%s">&times;</a>', 
esc_url( WC()->cart->get_remove_url( $cart_item_key ) ),
 __( 'Remove this item', 'woocommerce' ) ), $cart_item_key );

請注意WC()->cart而不是$woocommerce->cart希望如果上述解決方案也不起作用的話,可以對其他人有所幫助:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM