lorro

WooCommerce - Add shipping logos after shipping methods

Jan 20th, 2021 (edited)
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2. // add shipping logos after shipping methods
  3. add_action( 'woocommerce_after_shipping_rate', 'shipping_logos', 10 );
  4. function shipping_logos( $method ) {
  5.   $label = $method->get_label();
  6.   switch( $label ) {
  7.     case 'DHL':
  8.       print '<img src="http://www.my-domain.co.uk/wp-content/uploads/DHL-logo.png" class="shipping_logo">';
  9.       break;
  10.     case 'EMS':
  11.       print '<img src="http://www.my-domain.co.uk/wp-content/uploads/EMS-logo.png" class="shipping_logo">';
  12.       break;
  13.     default:
  14.   }
  15. }
  16.  
  17. /*
  18. The labels in the case statements must correspond to the labels used when setting up the corresponding shipping methods. The logo srcs come from the logos you must have uploaded to your media library.
  19. Works with themes which use the default WooCommerce hooks.
  20. */
Add Comment
Please, Sign In to add comment