WoocommerceCustomCheckoutVATField

The WooCommerce VAT WoocommerceCustomCheckoutVATField class.

Defined (2)

The class is defined in the following location(s).

/1.0.1/woocommerce-vat.php  
  1. class WoocommerceCustomCheckoutVATField { 
  2.  
  3. public function __construct() { 
  4. // Installation 
  5. if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); 
  6.  
  7. add_action( 'woocommerce_init', array( $this, 'init' ) ); 
  8.  
  9. public function init() { 
  10.  
  11. add_filter( 'woocommerce_checkout_fields' , array( $this, 'VAT_override_checkout_fields' )); 
  12. add_action( 'woocommerce_admin_order_data_after_billing_address', array( $this, 'VAT_custom_checkout_field_order_meta_keys' )); 
  13.  
  14.  
  15.  
  16.  
  17. // Our hooked in function - $fields is passed via the filter! 
  18. public function VAT_override_checkout_fields( $fields ) { 
  19. $fields['billing']['VAT_cui'] = array( 
  20. 'label' => __('VAT', 'woocommerce'),  
  21. 'placeholder' => _x('VAT', 'placeholder', 'woocommerce'),  
  22. 'required' => true,  
  23. 'class' => array('form-row-wide'),  
  24. 'clear' => true 
  25. ); 
  26.  
  27. return $fields; 
  28.  
  29. public function VAT_custom_checkout_field_order_meta_keys( $order ) { 
  30. echo "<p><strong>VAT:</strong>" . 
  31. //$order->order_custom_fields['_VAT_cui'][0] . "</p>"; 
  32. get_post_meta( $order->id, '_VAT_cui', true ) . "</p>"; 
  33.  
  34.  
  35.  
  36. public static function is_woocommerce_active() { 
  37.  
  38. $active_plugins = (array) get_option( 'active_plugins', array() ); 
  39.  
  40. if ( is_multisite() ) 
  41. $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); 
  42.  
  43. return in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins ); 
  44.  
  45.  
  46.  
  47.  
  48. /** Lifecycle methods ******************************************************/ 
  49.  
  50.  
  51. /** 
  52. * Run every time. Used since the activation hook is not executed when updating a plugin 
  53. */ 
  54. private function install() { 
  55.  
  56.  
  57.  
/woocommerce-vat.php  
  1. class WoocommerceCustomCheckoutVATField { 
  2.  
  3. public function __construct() { 
  4. // Installation 
  5. if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); 
  6.  
  7. add_action( 'woocommerce_init', array( $this, 'init' ) ); 
  8.  
  9. public function init() { 
  10.  
  11. add_filter( 'woocommerce_checkout_fields' , array( $this, 'VAT_override_checkout_fields' )); 
  12. add_action( 'woocommerce_admin_order_data_after_billing_address', array( $this, 'VAT_custom_checkout_field_order_meta_keys' )); 
  13.  
  14.  
  15.  
  16.  
  17. // Our hooked in function - $fields is passed via the filter! 
  18. public function VAT_override_checkout_fields( $fields ) { 
  19. $fields['billing']['VAT_cui'] = array( 
  20. 'label' => __('VAT', 'woocommerce'),  
  21. 'placeholder' => _x('VAT', 'placeholder', 'woocommerce'),  
  22. 'required' => true,  
  23. 'class' => array('form-row-wide'),  
  24. 'clear' => true 
  25. ); 
  26.  
  27. return $fields; 
  28.  
  29. public function VAT_custom_checkout_field_order_meta_keys( $order ) { 
  30. echo "<p><strong>VAT:</strong>" . 
  31. //$order->order_custom_fields['_VAT_cui'][0] . "</p>"; 
  32. get_post_meta( $order->id, '_VAT_cui', true ) . "</p>"; 
  33.  
  34.  
  35.  
  36. public static function is_woocommerce_active() { 
  37.  
  38. $active_plugins = (array) get_option( 'active_plugins', array() ); 
  39.  
  40. if ( is_multisite() ) 
  41. $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); 
  42.  
  43. return in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins ); 
  44.  
  45.  
  46.  
  47.  
  48. /** Lifecycle methods ******************************************************/ 
  49.  
  50.  
  51. /** 
  52. * Run every time. Used since the activation hook is not executed when updating a plugin 
  53. */ 
  54. private function install() { 
  55.  
  56.  
  57.