1 回答

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊
您需要更改display子主題style.css文件中圖標(biāo)的 css 屬性:
#shipping_method label > img {
display: inline-block;
}
因此,您可以在以下代碼中對(duì)其進(jìn)行測(cè)試,其中樣式在圖標(biāo)上進(jìn)行了硬編碼:
add_filter( 'woocommerce_cart_shipping_method_full_label', 'filter_woocommerce_cart_shipping_method_full_label', 10, 2 );
function filter_woocommerce_cart_shipping_method_full_label( $label, $method ) {
$style = ' style="display:inline-block;"'; // Style applied to the thumbnails
// Use the condition here with $method to apply the image to a specific method.
if( $method->method_id == "flat_rate" ) {
$label = ' <img src="https://www.website-link/wp-content/uploads/2020/08/002-truck.png"'.$style.'> ' . $label;
} else if( $method->method_id == "local_pickup" ) {
$label = ' <img src="https://www.website-link/wp-content/uploads/2020/08/001-discount.png"'.$style.'> ' . $label;
}
return $label;
}
代碼位于活動(dòng)子主題(或活動(dòng)主題)的functions.php 文件中。經(jīng)過測(cè)試并有效。
- 1 回答
- 0 關(guān)注
- 121 瀏覽
添加回答
舉報(bào)