pustakakoran

Menghapus Field checkout WooCommerce

May 28th, 2020
18
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Pastekan kode berikut di functions.php theme
  2.  
  3. Atau pakai plugin ini juga bisa: https://wordpress.org/plugins/wooenhancer/
  4.  
  5. MASIH ADA EMAIL:
  6. ========================================
  7. /*Remove fields in checkout page and Address in Account pages*/
  8.  
  9. add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
  10. add_filter( 'woocommerce_billing_fields' , 'custom_override_billing_fields' );
  11. add_filter( 'woocommerce_shipping_fields' , 'custom_override_shipping_fields' );
  12.  
  13. function custom_override_checkout_fields( $fields ) {
  14. unset($fields['billing']['billing_country']);
  15. unset($fields['shipping']['shipping_country']);
  16. unset($fields['billing']['billing_company']);
  17. unset($fields['shipping']['shipping_company']);
  18. unset($fields['billing']['billing_address_1']);
  19. unset($fields['shipping']['shipping_address_1']);
  20. unset($fields['billing']['billing_address_2']);
  21. unset($fields['shipping']['shipping_address_2']);
  22. unset($fields['billing']['billing_state']);
  23. unset($fields['shipping']['shipping_state']);
  24. unset($fields['billing']['billing_postcode']);
  25. unset($fields['shipping']['shipping_postcode']);
  26.  
  27. unset($fields['shipping']['shipping_email']);
  28. return $fields;
  29. }
  30.  
  31. function custom_override_billing_fields( $fields ) {
  32. unset($fields['billing_country']);
  33. unset($fields['billing']['billing_company']);
  34. unset($fields['billing']['billing_address_1']);
  35. unset($fields['billing']['billing_address_2']);
  36. unset($fields['billing']['billing_state']);
  37. unset($fields['billing']['billing_postcode']);
  38. unset($fields['billing']['billing_email']);
  39. return $fields;
  40. }
  41.  
  42. function custom_override_shipping_fields( $fields ) {
  43. unset($fields['shipping_country']);
  44. unset($fields['shipping']['shipping_company']);
  45. unset($fields['shipping']['shipping_address_1']);
  46. unset($fields['shipping']['shipping_address_2']);
  47. unset($fields['shipping']['shipping_state']);
  48. unset($fields['shipping']['shipping_postcode']);
  49. unset($fields['shipping']['shipping_email']);
  50. return $fields;
  51. }
  52.  
  53. TANPA EMAIL:
  54. ==================================================
  55. /*Remove fields in checkout page and Address in Account pages*/
  56.  
  57. add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
  58. add_filter( 'woocommerce_billing_fields' , 'custom_override_billing_fields' );
  59. add_filter( 'woocommerce_shipping_fields' , 'custom_override_shipping_fields' );
  60.  
  61. function custom_override_checkout_fields( $fields ) {
  62. unset($fields['billing']['billing_country']);
  63. unset($fields['shipping']['shipping_country']);
  64. unset($fields['billing']['billing_company']);
  65. unset($fields['shipping']['shipping_company']);
  66. unset($fields['billing']['billing_address_1']);
  67. unset($fields['shipping']['shipping_address_1']);
  68. unset($fields['billing']['billing_address_2']);
  69. unset($fields['shipping']['shipping_address_2']);
  70. unset($fields['billing']['billing_state']);
  71. unset($fields['shipping']['shipping_state']);
  72. unset($fields['billing']['billing_postcode']);
  73. unset($fields['shipping']['shipping_postcode']);
  74. unset($fields['billing']['billing_email']);
  75. unset($fields['shipping']['shipping_email']);
  76. return $fields;
  77. }
  78.  
  79. function custom_override_billing_fields( $fields ) {
  80. unset($fields['billing_country']);
  81. unset($fields['billing']['billing_company']);
  82. unset($fields['billing']['billing_address_1']);
  83. unset($fields['billing']['billing_address_2']);
  84. unset($fields['billing']['billing_state']);
  85. unset($fields['billing']['billing_postcode']);
  86. unset($fields['billing']['billing_email']);
  87. return $fields;
  88. }
  89.  
  90. function custom_override_shipping_fields( $fields ) {
  91. unset($fields['shipping_country']);
  92. unset($fields['shipping']['shipping_company']);
  93. unset($fields['shipping']['shipping_address_1']);
  94. unset($fields['shipping']['shipping_address_2']);
  95. unset($fields['shipping']['shipping_state']);
  96. unset($fields['shipping']['shipping_postcode']);
  97. unset($fields['shipping']['shipping_email']);
  98. return $fields;
  99. }
RAW Paste Data