1 回答

TA贡献1725条经验 获得超7个赞
您需要更改display子主题style.css文件中图标的 css 属性:
#shipping_method label > img {
display: inline-block;
}
因此,您可以在以下代码中对其进行测试,其中样式在图标上进行了硬编码:
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;
}
代码位于活动子主题(或活动主题)的functions.php 文件中。经过测试并有效。
- 1 回答
- 0 关注
- 92 浏览
添加回答
举报