AeliaWCEU_VAT_AssistantWCPDFEU_Invoice_Order

Extends AeliaWCEU_VAT_AssistantOrder class by adding some tweakings that simplify the rendering of an invoice in multiple currencies using the PDF Invoices and Packing Slips plugin.

Defined (1)

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

/src/lib/classes/integration/pdf_invoices_packing_slips/eu_invoice_order.php  
  1. class EU_Invoice_Order extends \Aelia\WC\EU_VAT_Assistant\Order { 
  2. protected $currency; 
  3.  
  4. /** 
  5. * Constructor. 
  6. * @param int order_id The order ID. 
  7. */ 
  8. public function __construct($order_id) { 
  9. parent::__construct($order_id); 
  10. $this->original_order_currency = parent::get_currency(); 
  11.  
  12. /** 
  13. * Allows to override the order currency. This can be used as a trick when 
  14. * printing an invoice in a different currency. 
  15. * @param string currency Sets the currency against the order. 
  16. */ 
  17. public function override_currency($currency) { 
  18. $this->currency = $currency; 
  19.  
  20. /** 
  21. * Returns the order currency. This method has been tweaked to allow passing 
  22. * a currency different from the one in which the order was actually placed. 
  23. * This is necessary to print invoices in multple currencies, because order 
  24. * amounts will be converted to the appropriate values by the 
  25. * EU_Invoice_Helper, but the formatting itself will occur within the 
  26. * order class, calling the get_order_currency() method (i.e. it's not possible 
  27. * to alter the currency from the outside). By overriding this method, we can 
  28. * change the currency to the appropriate one and ensure that the correct 
  29. * symbol is displayed. 
  30. * @return string A currency code. 
  31. */ 
  32. public function get_currency($context = 'view') { 
  33. if(empty($this->currency)) { 
  34. $this->currency = parent::get_currency($context); 
  35. return $this->currency;