Adding custom icons to the shipping options in Woocommerce Cart and Checkout

后端 未结 1 554
自闭症患者
自闭症患者 2021-01-07 14:30

I want to add icons to the shipping options in Woocommerce Cart and Checkout.

For example in the \"local pickup\" option I want to show a little store icon beside th

相关标签:
1条回答
  • 2021-01-07 15:02

    Use the woocommerce_cart_shipping_method_full_label filter.

    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 ) { 
       // Use the condition here with $method to apply the image to a specific method.      
    
       if( $method->method_id == "flat_rate" ) {
           $label = $label."Your Icon Image";
       } else if( $method->method_id == "local_pickup" ) {
           $label = $label."Your Icon Image";       
       }
       return $label; 
    }
    
    0 讨论(0)
提交回复
热议问题