WCML_Exchange_Rates_UI

The WooCommerce Multilingual WCML Exchange Rates UI class.

Defined (1)

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

/inc/template-classes/multi-currency/class-wcml-exchange-rates-ui.php  
  1. class WCML_Exchange_Rates_UI extends WPML_Templates_Factory { 
  2.  
  3. /** 
  4. * @var woocommerce_wpml 
  5. */ 
  6. private $woocommerce_wpml; 
  7. /** 
  8. * @var array 
  9. */ 
  10. private $services; 
  11. /** 
  12. * @var array 
  13. */ 
  14. private $settings; 
  15.  
  16. function __construct( $woocommerce_wpml ) { 
  17. parent::__construct(); 
  18.  
  19. $this->woocommerce_wpml =& $woocommerce_wpml; 
  20. $services = $this->woocommerce_wpml->multi_currency->exchange_rate_services->get_services(); 
  21. $this->settings = $this->woocommerce_wpml->multi_currency->exchange_rate_services->get_settings(); 
  22.  
  23. foreach( $services as $id => $service ) { 
  24. $this->services[ $id ] = array( 
  25. 'name' => $service->get_name(),  
  26. 'url' => $service->get_url(),  
  27. 'requires_key' => $service->is_key_required(),  
  28. 'api_key' => $service->get_setting( 'api-key' ),  
  29. 'last_error' => $service->get_last_error() 
  30. ); 
  31.  
  32. public function get_model() { 
  33.  
  34. $last_updated = empty( $this->settings['last_updated'] ) ? 
  35. '<i>' . __( 'never', 'woocommerce-multilingual' ) . '</i>' : 
  36. date_i18n( 'F j, Y g:i a', $this->settings['last_updated'] ); 
  37.  
  38. $model = array( 
  39. 'strings' => array( 
  40.  
  41. 'header' => __( 'Automatic Exchange Rates', 'woocommerce-multilingual' ),  
  42. 'no_currencies' => __( "You haven't added any secondary currencies.", 'woocommerce-multilingual' ),  
  43. 'enable_automatic' => __( 'Enable automatic exchange rates', 'woocommerce-multilingual' ),  
  44. 'services_label' => __( 'Exchange rates source', 'woocommerce-multilingual' ),  
  45. 'lifting_label' => __( 'Lifting charge', 'woocommerce-multilingual' ),  
  46. 'lifting_details1' => __( 'The lifting charge adjusts the exchange rate provided by the selected service before it is saved. The exchange rates displayed in the table above include the lifting charge.', 'woocommerce-multilingual' ),  
  47. 'lifting_details2' => __( 'Exchange rate = %s exchange rate x (1 + lifting charge / 100)', 'woocommerce-multilingual' ),  
  48. 'services_api' => __( 'API key (required)', 'woocommerce-multilingual' ),  
  49. 'frequency' => __( 'Update frequency', 'woocommerce-multilingual' ),  
  50. 'update' => __( 'Update manually now', 'woocommerce-multilingual' ),  
  51. 'update_tip' => __( 'You have to save all settings before updating exchange rates', 'woocommerce-multilingual' ),  
  52. 'manually' => __( 'Manually', 'woocommerce-multilingual'),  
  53. 'daily' => __( 'Daily', 'woocommerce-multilingual' ),  
  54. 'weekly' => __( 'Weekly on', 'woocommerce-multilingual' ),  
  55. 'monthly' => __( 'Monthly on the', 'woocommerce-multilingual' ),  
  56. 'key_placeholder' => __( 'Enter API key', 'woocommerce-multilingual' ),  
  57. 'key_required' => __( 'API key (required)', 'woocommerce-multilingual' ),  
  58. 'nonce' => wp_create_nonce( 'update-exchange-rates' ),  
  59. 'updated_time' => sprintf( 
  60. __('Last updated: %s', 'woocommerce-multilingual' ),  
  61. '<span class="time">' . $last_updated . '</span>' 
  62. ),  
  63. 'updated_success' => __( 'Exchange rates updated successfully', 'woocommerce-multilingual' ),  
  64. 'visit_website' => __( 'Visit website', 'woocommerce-multilingual' ) 
  65.  
  66. ),  
  67.  
  68. 'services' => $this->services,  
  69. 'settings' => $this->settings,  
  70.  
  71. 'secondary_currencies' => $this->woocommerce_wpml->multi_currency->get_currencies(),  
  72.  
  73. ); 
  74.  
  75. return $model; 
  76.  
  77. protected function init_template_base_dir() { 
  78. $this->template_paths = array( 
  79. WCML_PLUGIN_PATH . '/templates/multi-currency/',  
  80. ); 
  81.  
  82. public function get_template() { 
  83. return 'exchange-rates.twig'; 
  84.