WCML_Pip

The WooCommerce Multilingual WCML Pip class.

Defined (1)

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

/compatibility/class-wcml-pip.php  
  1. class WCML_Pip{ 
  2.  
  3. function __construct() { 
  4.  
  5. add_filter( 'wcml_send_email_order_id', array( $this, 'wcml_send_email_order_id') ); 
  6. add_filter( 'woocommerce_currency_symbol', array( $this, 'filter_pip_currency_symbol' ) ); 
  7. add_filter( 'wcml_filter_currency_position', array( $this, 'filter_pip_currency_position' ) ); 
  8.  
  9.  
  10. public function wcml_send_email_order_id( $order_id ) { 
  11.  
  12. $pip_order_id = $this->get_pip_order_id(); 
  13.  
  14. if( $pip_order_id ) { 
  15. $order_id = $pip_order_id; 
  16.  
  17. return $order_id; 
  18.  
  19.  
  20. public function filter_pip_currency_symbol( $currency_symbol ) { 
  21.  
  22. remove_filter( 'woocommerce_currency_symbol', array( $this, 'filter_pip_currency_symbol' ) ); 
  23.  
  24. $currency = $this->get_pip_order_currency( ); 
  25.  
  26. if( $currency ) { 
  27. $currency_symbol = get_woocommerce_currency_symbol( $currency ); 
  28.  
  29. add_filter( 'woocommerce_currency_symbol', array( $this, 'filter_pip_currency_symbol' ) ); 
  30.  
  31. return $currency_symbol; 
  32.  
  33. public function filter_pip_currency_position( $currency ) { 
  34.  
  35. remove_filter( 'wcml_filter_currency_position', array( $this, 'filter_pip_currency_position' ) ); 
  36.  
  37. $currency = $this->get_pip_order_currency( $currency ); 
  38.  
  39. add_filter( 'wcml_filter_currency_position', array( $this, 'filter_pip_currency_position' ) ); 
  40.  
  41. return $currency; 
  42.  
  43.  
  44. public function get_pip_order_id() { 
  45.  
  46. $order_id = false; 
  47.  
  48. if( isset( $_GET[ 'wc_pip_action' ] ) && isset( $_GET[ 'order_id' ] ) ) { 
  49. $order_id = $_GET[ 'order_id' ]; 
  50. }elseif( 
  51. isset( $_POST[ 'action' ] ) && 
  52. $_POST[ 'action' ] == 'wc_pip_order_send_email' || 
  53. $_POST[ 'action' ] == 'wc_pip_send_email_packing_list' 
  54. ) && 
  55. isset( $_POST[ 'order_id' ] ) 
  56. ) { 
  57. $order_id = $_POST[ 'order_id' ]; 
  58.  
  59. return $order_id; 
  60.  
  61. public function get_pip_order_currency( $currency = false ) { 
  62.  
  63. $pip_order_id = $this->get_pip_order_id(); 
  64.  
  65. if( $pip_order_id && isset( WC()->order_factory ) ) { 
  66.  
  67. $the_order = WC()->order_factory->get_order( $pip_order_id ); 
  68.  
  69. if( $the_order ) { 
  70. $currency = WooCommerce_Functions_Wrapper::get_order_currency( $the_order ); 
  71.  
  72. if( !$currency && isset( $_COOKIE[ '_wcml_order_currency' ] ) ) { 
  73. $currency = $_COOKIE[ '_wcml_order_currency' ]; 
  74.  
  75.  
  76. return $currency; 
  77.  
  78.