WC_Correios_Shipping_Impresso

Default Correios Impresso shipping method abstract class.

Defined (1)

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

/includes/abstracts/abstract-wc-correios-shipping-impresso.php  
  1. abstract class WC_Correios_Shipping_Impresso extends WC_Correios_Shipping_Carta { 
  2.  
  3. /** 
  4. * National Registry cost. 
  5. * Cost based in 01/10/2016 from: 
  6. * http://www.correios.com.br/para-voce/consultas-e-solicitacoes/precos-e-prazos/servicos-adicionais-nacionais 
  7. * @var float 
  8. */ 
  9. protected $national_registry_cost = 4.30; 
  10.  
  11. /** 
  12. * Reasonable Registry cost. 
  13. * Cost based in 01/10/2016 from: 
  14. * http://www.correios.com.br/para-voce/consultas-e-solicitacoes/precos-e-prazos/servicos-adicionais-nacionais 
  15. * @var float 
  16. */ 
  17. protected $reasonable_registry_cost = 2.15; 
  18.  
  19. /** 
  20. * Receipt Notice cost. 
  21. * Cost based in 01/10/2016 from: 
  22. * https://www.correios.com.br/para-voce/consultas-e-solicitacoes/precos-e-prazos/servicos-adicionais-nacionais 
  23. * @var float 
  24. */ 
  25. protected $receipt_notice_cost = 4.30; 
  26.  
  27. /** 
  28. * Own Hands cost. 
  29. * Cost based in 01/10/2016 from: 
  30. * https://www.correios.com.br/para-voce/consultas-e-solicitacoes/precos-e-prazos/servicos-adicionais-nacionais 
  31. * @var float 
  32. */ 
  33. protected $own_hands_cost = 5.50; 
  34.  
  35. /** 
  36. * Weight limit for reasonable registry. 
  37. * Value based in 01/02/2017 from: 
  38. * https://www.correios.com.br/para-voce/consultas-e-solicitacoes/precos-e-prazos/servicos-nacionais_pasta/impresso-normal 
  39. * @var float 
  40. */ 
  41. protected $reasonable_registry_weight_limit = 500.000; 
  42.  
  43. /** 
  44. * Initialize Impresso shipping method. 
  45. * @param int $instance_id Shipping zone instance. 
  46. */ 
  47. public function __construct( $instance_id = 0 ) { 
  48. $this->instance_id = absint( $instance_id ); 
  49. $this->method_description = sprintf( __( '%s is a shipping method from Correios.', 'woocommerce-correios' ), $this->method_title ); 
  50. $this->supports = array( 
  51. 'shipping-zones',  
  52. 'instance-settings',  
  53. ); 
  54.  
  55. // Load the form fields. 
  56. $this->init_form_fields(); 
  57.  
  58. // Define user set variables. 
  59. $this->enabled = $this->get_option( 'enabled' ); 
  60. $this->title = $this->get_option( 'title' ); 
  61. $this->shipping_class = $this->get_option( 'shipping_class' ); 
  62. $this->registry_type = $this->get_option( 'registry_type' ); 
  63. $this->show_delivery_time = $this->get_option( 'show_delivery_time' ); 
  64. $this->additional_time = $this->get_option( 'additional_time' ); 
  65. $this->fee = $this->get_option( 'fee' ); 
  66. $this->receipt_notice = $this->get_option( 'receipt_notice' ); 
  67. $this->own_hands = $this->get_option( 'own_hands' ); 
  68. $this->debug = $this->get_option( 'debug' ); 
  69.  
  70. // Active logs. 
  71. if ( 'yes' === $this->debug ) { 
  72. $this->log = new WC_Logger(); 
  73.  
  74. // Save admin options. 
  75. add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); 
  76.  
  77. /** 
  78. * Admin options fields. 
  79. */ 
  80. public function init_form_fields() { 
  81. $this->instance_form_fields = array( 
  82. 'enabled' => array( 
  83. 'title' => __( 'Enable/Disable', 'woocommerce-correios' ),  
  84. 'type' => 'checkbox',  
  85. 'label' => __( 'Enable this shipping method', 'woocommerce-correios' ),  
  86. 'default' => 'yes',  
  87. ),  
  88. 'title' => array( 
  89. 'title' => __( 'Title', 'woocommerce-correios' ),  
  90. 'type' => 'text',  
  91. 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-correios' ),  
  92. 'desc_tip' => true,  
  93. 'default' => $this->method_title,  
  94. ),  
  95. 'behavior_options' => array( 
  96. 'title' => __( 'Behavior Options', 'woocommerce-correios' ),  
  97. 'type' => 'title',  
  98. 'default' => '',  
  99. ),  
  100. 'shipping_class' => array( 
  101. 'title' => __( 'Shipping Class', 'woocommerce-correios' ),  
  102. 'type' => 'select',  
  103. 'description' => __( 'Select for which shipping class this method will be applied.', 'woocommerce-correios' ),  
  104. 'desc_tip' => true,  
  105. 'default' => '',  
  106. 'class' => 'wc-enhanced-select',  
  107. 'options' => $this->get_shipping_classes_options(),  
  108. ),  
  109. 'registry_type' => array( 
  110. 'title' => __( 'Registry Type', 'woocommerce-correios' ),  
  111. 'type' => 'select',  
  112. 'description' => __( 'Select for which registry type this method will be applied.', 'woocommerce-correios' ),  
  113. 'desc_tip' => true,  
  114. 'default' => '',  
  115. 'class' => 'wc-enhanced-select',  
  116. 'options' => array( 
  117. '' => __( '-- Select a registry type --', 'woocommerce-correios' ),  
  118. 'RN' => __( 'Registro Nacional', 'woocommerce-correios' ),  
  119. 'RM' => __( 'Registro Mdico', 'woocommerce-correios' ),  
  120. ),  
  121. 'default' => 'RM',  
  122. ),  
  123. 'show_delivery_time' => array( 
  124. 'title' => __( 'Delivery Time', 'woocommerce-correios' ),  
  125. 'type' => 'checkbox',  
  126. 'label' => __( 'Show estimated delivery time', 'woocommerce-correios' ),  
  127. 'description' => __( 'Display the estimated delivery time in working days.', 'woocommerce-correios' ),  
  128. 'desc_tip' => true,  
  129. 'default' => 'no',  
  130. ),  
  131. 'additional_time' => array( 
  132. 'title' => __( 'Delivery Days', 'woocommerce-correios' ),  
  133. 'type' => 'text',  
  134. 'description' => __( 'Working days to the estimated delivery.', 'woocommerce-correios' ),  
  135. 'desc_tip' => true,  
  136. 'default' => '0',  
  137. 'placeholder' => '0',  
  138. ),  
  139. 'fee' => array( 
  140. 'title' => __( 'Handling Fee', 'woocommerce-correios' ),  
  141. 'type' => 'price',  
  142. 'description' => __( 'Enter an amount, e.g. 2.50, or a percentage, e.g. 5%. Leave blank to disable.', 'woocommerce-correios' ),  
  143. 'desc_tip' => true,  
  144. 'placeholder' => '0.00',  
  145. 'default' => '',  
  146. ),  
  147. 'optional_services' => array( 
  148. 'title' => __( 'Optional Services', 'woocommerce-correios' ),  
  149. 'type' => 'title',  
  150. 'description' => __( 'Use these options to add the value of each service provided by the Correios.', 'woocommerce-correios' ),  
  151. 'default' => '',  
  152. ),  
  153. 'receipt_notice' => array( 
  154. 'title' => __( 'Receipt Notice', 'woocommerce-correios' ),  
  155. 'type' => 'checkbox',  
  156. 'label' => __( 'Enable receipt notice', 'woocommerce-correios' ),  
  157. 'description' => __( 'This controls whether to add costs of the receipt notice service.', 'woocommerce-correios' ),  
  158. 'desc_tip' => true,  
  159. 'default' => 'no',  
  160. ),  
  161. 'own_hands' => array( 
  162. 'title' => __( 'Own Hands', 'woocommerce-correios' ),  
  163. 'type' => 'checkbox',  
  164. 'label' => __( 'Enable own hands', 'woocommerce-correios' ),  
  165. 'description' => __( 'This controls whether to add costs of the own hands service', 'woocommerce-correios' ),  
  166. 'desc_tip' => true,  
  167. 'default' => 'no',  
  168. ),  
  169. 'testing' => array( 
  170. 'title' => __( 'Testing', 'woocommerce-correios' ),  
  171. 'type' => 'title',  
  172. 'default' => '',  
  173. ),  
  174. 'debug' => array( 
  175. 'title' => __( 'Debug Log', 'woocommerce-correios' ),  
  176. 'type' => 'checkbox',  
  177. 'label' => __( 'Enable logging', 'woocommerce-correios' ),  
  178. 'default' => 'no',  
  179. 'description' => sprintf( __( 'Log %s events, such as WebServices requests.', 'woocommerce-correios' ), $this->method_title ) . $this->get_log_link(),  
  180. ),  
  181. );