Changeset 2765806
- Timestamp:
- 08/03/2022 01:26:29 PM (4 years ago)
- Location:
- unienvios/trunk
- Files:
-
- 3 edited
-
ClassUnienvios.php (modified) (5 diffs)
-
index.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
unienvios/trunk/ClassUnienvios.php
r2642517 r2765806 14 14 $this->title = $this->get_option('title'); // This can be added as an setting but for this example its forced. 15 15 $this->enabled = $this->get_option('enabled'); 16 // $this->delivery_time = $this->get_option('delivery_time'); 17 // $this->calculator = $this->get_option('calculator'); 16 18 17 19 … … 32 34 { 33 35 $this->form_fields = array( 36 'title' => array( 37 'title' => __('Título'), 38 'type' => 'text', 39 'description' => __('Isso controla o título que o usuário vê durante o checkout.'), 40 'default' => __($this->method_title), 41 'desc_tip' => true 42 ), 34 43 'enabled' => array( 35 44 'title' => __('Ativar/Desativar'), … … 38 47 'default' => 'yes', 39 48 ), 40 'title' => array( 41 'title' => __('Título'), 42 'type' => 'text', 43 'description' => __('Isso controla o título que o usuário vê durante o checkout.'), 44 'default' => __($this->method_title), 45 'desc_tip' => true 46 ) 49 // 'delivery_time' => array( 50 // 'title' => __('Ativar/Desativar Prazo de Entrega'), 51 // 'type' => 'checkbox', 52 // 'label' => __('Mostrar prazo de entrega no carrinho'), 53 // 'default' => 'yes', 54 // ), 55 // 'calculator' => array( 56 // 'title' => __('Ativar/Desativar Calculadora de Frete'), 57 // 'type' => 'checkbox', 58 // 'label' => __('Ativar ou desativar campo de calcular frete na página do produto'), 59 // 'default' => 'yes', 60 // ), 47 61 ); 48 62 } // End init_form_fields() … … 117 131 ]; 118 132 119 // wc_add_notice( __('debug: ', 'woothemes') . json_encode($dimensoes), 'error' ); 120 // return; 121 122 // wp_send_json($dimensoes); 123 124 $api = new API_UNIENVIOS('https://api.unienvios.com.br'); 125 $dados = []; 126 $dados['email'] = get_option('unienvios_options')['email']; 127 $dados['senha'] = get_option('unienvios_options')['senha']; 128 $dados['cep'] = str_replace("-", "", $package['destination']['postcode']); 129 $dados['cart_subtotal'] = doubleval($package['cart_subtotal']); 130 131 132 133 if ($dados['cep'] != "") { 134 $quotation = $api->create_quotation($dados, $dimensoes); 135 foreach ($quotation->quotations as $key => $qut) { 136 137 138 $name_minusculo = preg_replace("/[^\w\s]/", "", iconv("UTF-8", "ASCII//TRANSLIT", $qut->name)); 139 $name_minusculo = strtolower(str_replace(" ", "_", $name_minusculo)); 140 141 if ($name_minusculo == $this->id) { 142 $rate = array( 143 'label' => $this->title, 144 'cost' => $qut->final_price, 145 'calc_tax' => 'per_item' 146 ); 147 133 134 // wp_send_json($dimensoes); 135 136 $api = new API_UNIENVIOS('https://api.unienvios.com.br'); 137 $dados = []; 138 $dados['email'] = get_option('unienvios_options')['email']; 139 $dados['senha'] = get_option('unienvios_options')['senha']; 140 $dados['cep'] = str_replace("-", "", $package['destination']['postcode']); 141 $dados['cart_subtotal'] = doubleval($package['cart_subtotal']); 142 143 144 145 if ($dados['cep'] != "") { 146 $quotation = $api->create_quotation($dados, $dimensoes); 147 $array_delivery_time = []; 148 149 foreach ($quotation->quotations as $key => $qut) { 150 151 $name_minusculo = preg_replace("/[^\w\s]/", "", iconv("UTF-8", "ASCII//TRANSLIT", $qut->name)); 152 $name_minusculo = strtolower(str_replace(" ", "_", $name_minusculo)); 153 154 array_push($array_delivery_time, ['qut_label' => $qut->name,'time'=>$qut->delivery_time]); 155 156 if ($name_minusculo == $this->id) { 157 $rate = array( 158 'label' => $this->title, 159 'cost' => $qut->final_price, 160 'calc_tax' => 'per_item', 161 'delivery_time' => $qut->delivery_time 162 ); 163 // wc_add_notice( __('debug: ', 'woothemes') . json_encode($rate), 'error' ); 164 // return; 165 148 166 // Register the rate 149 167 $this->add_rate($rate); … … 173 191 } 174 192 } 193 194 WC()->session->set( 195 'array_delivery_time', 196 $array_delivery_time 197 ); 175 198 } 176 199 } -
unienvios/trunk/index.php
r2752564 r2765806 4 4 Plugin URI: https://unienvios.com.br/ 5 5 Description: Plugin de Entrega 6 Version: 1. 2.26 Version: 1.3.0 7 7 Author: Unienvios 8 8 Author URI: https://unienvios.com.br/ … … 192 192 193 193 // add_action('woocommerce_init', 'teste2'); 194 195 function shipping_delivery_forecast( $shipping_method ) { 196 197 $array_deliverys_times = WC()->session->get('array_delivery_time'); 198 // var_dump($shipping_method->label); 199 foreach($array_deliverys_times as $times){ 200 if($times['qut_label'] == $shipping_method->label){ 201 $total = $times['time']; 202 } 203 } 204 205 if ( $total ) { 206 /* translators: %d: days to delivery */ 207 echo '<p><small>' . esc_html( sprintf( _n( 'Entrega em %d dia útil', 'Entrega em %d dias úteis', $total, 'unienvios' ), $total ) ) . '</small></p>'; 208 } 209 } 210 211 add_action( 'woocommerce_after_shipping_rate', 'shipping_delivery_forecast' , 100 ); -
unienvios/trunk/readme.txt
r2752559 r2765806 5 5 Requires at least: 4.7 6 6 Tested up to: 5.8 7 Stable tag: 1. 2.27 Stable tag: 1.3.0 8 8 Requires PHP: 7.2 9 9 License: GPLv3 or later … … 71 71 72 72 * Adicionado calculo de medidas 73 74 * Adicionado prazo de entrega no carrinho 75 = 1.3.0 =
Note: See TracChangeset
for help on using the changeset viewer.