亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

WooCommerce:更改刪除購物車中的優惠券鏈接

WooCommerce:更改刪除購物車中的優惠券鏈接

PHP
拉莫斯之舞 2023-08-26 17:39:14
我想更改購物車中的刪除優惠券鏈接。目前,括號中是“Remove”一詞:[Remove]。wc_cart_totals_coupon_html我在模板中找到了該功能cart-totals.php。我還找到了該函數內部的鏈接。$coupon_html = $discount_amount_html . ' <a href="' . esc_url( add_query_arg( 'remove_coupon', rawurlencode( $coupon->get_code() ), defined( 'WOOCOMMERCE_CHECKOUT' ) ? wc_get_checkout_url() : wc_get_cart_url() ) ) . '" class="woocommerce-remove-coupon" data-coupon="' . esc_attr( $coupon->get_code() ) . '">' . __( '[Remove]', 'woocommerce' ) . '</a>';我只是不知道如何更改該鏈接部分。wc_cart_totals_coupon_label( $coupon );如果鏈接出現在帶有標簽 ( ) 的表格單元格中,而不是顯示在帶有折扣金額的單元格中,那就太好了。但就目前而言,如果我能第一步更改鏈接,那確實會有幫助。
查看完整描述

2 回答

?
慕無忌1623718

TA貢獻1744條經驗 獲得超4個贊

wc-cart-functions.php包含第295行

echo wp_kses( apply_filters( 'woocommerce_cart_totals_coupon_html', $coupon_html, $coupon, $discount_amount_html ), array_replace_recursive( wp_kses_allowed_html( 'post' ), array( 'a' => array( 'data-coupon' => true ) ) ) ); // phpcs:ignore PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound

因此,要更改鏈接,您可以使用


function filter_woocommerce_cart_totals_coupon_html( $coupon_html, $coupon, $discount_amount_html ) {

? ? $coupon_html = $discount_amount_html . '<a >My url</a>';


? ? return $coupon_html;

}

add_filter( 'woocommerce_cart_totals_coupon_html', 'filter_woocommerce_cart_totals_coupon_html', 10, 3 );

要更改購物車中的表格單元格,您可以編輯第35-38cart/cart-totals.php行的文件



查看完整回答
反對 回復 2023-08-26
?
FFIVE

TA貢獻1797條經驗 獲得超6個贊

  1. 根據您的需要嘗試使用靜態 url 鏈接。

  2. 根據 WooCommerce 標準創建代碼。


查看完整回答
反對 回復 2023-08-26
  • 2 回答
  • 0 關注
  • 174 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號