Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. function new_orders_columns($columns)
  2. {
  3. unset($columns['shippging_address']);
  4.  
  5. return $columns;
  6. }
  7.  
  8. function after_woo()
  9. {
  10. add_filter('manage_shop_order_posts_columns', 'new_orders_columns', 10, 1);
  11. }
  12.  
  13. add_action('plugins_loaded', 'after_woo');
  14.  
  15. add_filter( 'manage_edit-shop_order_columns', 'remove_specific_orders_column' );
  16. function remove_specific_orders_column( $columns ){
  17. unset( $columns['shipping_address'] );
  18.  
  19. return $new_columns;
  20. }
  21.  
  22. add_filter( 'manage_edit-shop_order_columns', 'customizing_orders_columns' );
  23. function customizing_orders_columns( $columns ){
  24. $new_columns = [];
  25.  
  26. foreach ( $columns as $key => $column ) {
  27. if( $key === 'shipping_address' ) {
  28. $new_columns['shipping_addr_repl'] = $column;
  29. } else {
  30. $new_columns[$key] = $column;
  31. }
  32. }
  33. return $new_columns;
  34. }
  35.  
  36. add_action( 'manage_shop_order_posts_custom_column', 'set_custom_shipping_address_content_replacement' );
  37. function set_custom_shipping_address_content_replacement( $column ) {
  38. global $the_order, $post;
  39.  
  40. if ( 'shipping_addr_repl' === $column ) {
  41. // YOUR REPLACEMENT CODE (Fake example below)
  42. echo $the_order->get_shipping_city();
  43. }
  44. }
  45.  
  46. $address = $the_order->get_formatted_shipping_address();
  47.  
  48. if ( $address ) {
  49. echo '<a target="_blank" href="' . esc_url( $the_order->get_shipping_address_map_url() ) . '">' . esc_html( preg_replace( '#<brs*/?>#i', ', ', $address ) ) . '</a>';
  50. if ( $the_order->get_shipping_method() ) {
  51. /* translators: %s: shipping method */
  52. echo '<span class="description">' . sprintf( __( 'via %s', 'woocommerce' ), esc_html( $the_order->get_shipping_method() ) ) . '</span>'; // WPCS: XSS ok.
  53. }
  54. } else {
  55. echo '&ndash;';
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement