Changeset 1785038
- Timestamp:
- 12/11/2017 11:02:51 PM (8 years ago)
- Location:
- woo-oca/trunk
- Files:
-
- 5 edited
-
oca-class.php (modified) (11 diffs)
-
oca-shipping.php (modified) (1 diff)
-
oca-utilities.php (modified) (5 diffs)
-
readme.txt (modified) (4 diffs)
-
woocommerce-oca.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
woo-oca/trunk/oca-class.php
r1778731 r1785038 115 115 'title' => __( 'CUIT', 'woocommerce' ), 116 116 'default' => '', 117 'type' => 'text' 117 'type' => 'text', 118 'desc_tip' => true, 119 'description' => 'Formato XX-XXXXXXXX-X', 118 120 ), 119 121 'clase' => array( … … 177 179 'desc_tip' => true, 178 180 ), 181 'contrareembolso_operativa1' => array( 182 'title' => __( 'Contrareembolso?', 'woocommerce' ), 183 'type' => 'checkbox' 184 ), 179 185 'TituloOp2' => array( 180 186 'title' => __( 'Operativa 2', 'textdomain' ), … … 208 214 'desc_tip' => true, 209 215 ), 216 'contrareembolso_operativa2' => array( 217 'title' => __( 'Contrareembolso?', 'woocommerce' ), 218 'type' => 'checkbox' 219 ), 210 220 'TituloOp3' => array( 211 221 'title' => __( 'Operativa 3', 'textdomain' ), … … 239 249 'desc_tip' => true, 240 250 ), 251 'contrareembolso_operativa3' => array( 252 'title' => __( 'Contrareembolso?', 'woocommerce' ), 253 'type' => 'checkbox' 254 ), 241 255 'TituloOp4' => array( 242 256 'title' => __( 'Operativa 4', 'textdomain' ), … … 269 283 'default' => '', 270 284 'desc_tip' => true, 285 ), 286 'contrareembolso_operativa4' => array( 287 'title' => __( 'Contrareembolso?', 'woocommerce' ), 288 'type' => 'checkbox' 271 289 ) 272 290 ); … … 305 323 $accion = $this->verificar_clases($productos); 306 324 325 $peso_total = $precio_total = 0; 326 $hay_producto_cero = false; 327 foreach($productos as $producto){ 328 $peso_total += $producto['peso']; 329 $largo_total += $producto['largo']; 330 $ancho_total += $producto['ancho']; 331 $alto_total += $producto['alto']; 332 if($producto['peso'] == 0 || $producto['peso'] == '' || $producto['alto'] == 0 || $producto['alto'] == '' || $producto['largo'] == 0 || $producto['largo'] == '' || $producto['ancho'] == 0 || $producto['ancho'] == '' ){ 333 $hay_producto_cero = true; 334 $producto_cero = $producto; 335 break; 336 } 337 } 338 if($hay_producto_cero || $peso_total === '' || $largo_total === '' || $alto_total === '' || $ancho_total === ''){ 339 if($this->get_instance_option('debug') === 'yes'){ 340 $log = new WC_Logger(); 341 if(isset($producto_cero)){ 342 $log->add('oca','Detectado producto con malas dimensiones o peso: '); 343 $log->add('oca', print_r($producto_cero,true)); 344 }else{ 345 $log->add('oca','Detectado dimension/peso 0'); 346 } 347 } 348 return; 349 } 350 307 351 308 352 if($accion === 'envio_gratis' || $envio_gratis === 'yes'){ … … 319 363 $operativa_seleccionada = array_shift($nombre); 320 364 $tipo_operativa = array_shift($nombre); 365 $contrareembolso = array_shift($nombre); 321 366 $nombre = implode(" ", $nombre); 322 367 if($this->get_instance_option('debug') === 'yes'){ … … 347 392 } 348 393 } 349 $this->addRate('',$tarifa[0]['Total'], $nombre, $operativa_seleccionada, $tipo_operativa); 394 if($contrareembolso === 'yes'){ 395 $precio = number_format($tarifa[0]['Total'], 2); 396 if($precio == 0){ 397 $this->addRate('',0, $nombre.' (Pago a destino)', $operativa_seleccionada, $tipo_operativa, $tarifa[0]['Total'], 'yes'); 398 }else{ 399 $this->addRate('',0, $nombre.' (Pago a destino - $'.$precio.')', $operativa_seleccionada, $tipo_operativa, $tarifa[0]['Total'], 'yes'); 400 } 401 }else{ 402 $this->addRate('',$tarifa[0]['Total'], $nombre, $operativa_seleccionada, $tipo_operativa, $tarifa[0]['Total'], 'no'); 403 } 350 404 } 351 405 … … 463 517 private function cargar_operativas(){ 464 518 $res = array(); 465 $res['operativa1 '.$this->get_instance_option('tipo_operativa1').' '.$this->get_instance_option(' nombre_operativa1')] = $this->get_instance_option('operativa1');466 $res['operativa2 '.$this->get_instance_option('tipo_operativa2').' '.$this->get_instance_option(' nombre_operativa2')] = $this->get_instance_option('operativa2');467 $res['operativa3 '.$this->get_instance_option('tipo_operativa3').' '.$this->get_instance_option(' nombre_operativa3')] = $this->get_instance_option('operativa3');468 $res['operativa4 '.$this->get_instance_option('tipo_operativa4').' '.$this->get_instance_option(' nombre_operativa4')] = $this->get_instance_option('operativa4');519 $res['operativa1 '.$this->get_instance_option('tipo_operativa1').' '.$this->get_instance_option('contrareembolso_operativa1').' '.$this->get_instance_option('nombre_operativa1')] = $this->get_instance_option('operativa1'); 520 $res['operativa2 '.$this->get_instance_option('tipo_operativa2').' '.$this->get_instance_option('contrareembolso_operativa2').' '.$this->get_instance_option('nombre_operativa2')] = $this->get_instance_option('operativa2'); 521 $res['operativa3 '.$this->get_instance_option('tipo_operativa3').' '.$this->get_instance_option('contrareembolso_operativa3').' '.$this->get_instance_option('nombre_operativa3')] = $this->get_instance_option('operativa3'); 522 $res['operativa4 '.$this->get_instance_option('tipo_operativa4').' '.$this->get_instance_option('contrareembolso_operativa4').' '.$this->get_instance_option('nombre_operativa4')] = $this->get_instance_option('operativa4'); 469 523 $res = array_filter($res); 470 524 return $res; … … 521 575 * @return array 522 576 */ 523 public function addRate($tipo = '', $precio = '', $nombre = '' , $operativa = '', $tipo_op = '' ){577 public function addRate($tipo = '', $precio = '', $nombre = '' , $operativa = '', $tipo_op = '', $precio_declarado = '', $cr){ 524 578 if($tipo === 'gratis'){ 525 579 … … 534 588 535 589 $rate = array( 536 'id' => "oca ".$tipo_op." ".$this->get_instance_option_key()." ".$operativa ,590 'id' => "oca ".$tipo_op." ".$this->get_instance_option_key()." ".$operativa." ".$precio_declarado." ".$cr, 537 591 'label' => $nombre, 538 592 'cost' => $precio, -
woo-oca/trunk/oca-shipping.php
r1778731 r1785038 73 73 if($product->get_weight() !== ''){ 74 74 $peso = $product->get_weight(); 75 $xml .= '<paquete alto="'.wc_get_dimension( $product->get_height(), 'm').'" ancho="'.wc_get_dimension( $product->get_width(), 'm').'" largo="'.wc_get_dimension( $product->get_length(), 'm').'" peso="'.wc_get_weight( $peso , 'kg' ).'" valor=" 0" cant="1" />';75 $xml .= '<paquete alto="'.wc_get_dimension( $product->get_height(), 'm').'" ancho="'.wc_get_dimension( $product->get_width(), 'm').'" largo="'.wc_get_dimension( $product->get_length(), 'm').'" peso="'.wc_get_weight( $peso , 'kg' ).'" valor="'.$envio[4].'" cant="1" />'; 76 76 }else{ 77 77 $peso = $product_variado->get_weight(); 78 $xml .= '<paquete alto="'.wc_get_dimension( $product_variado->get_height(), 'm').'" ancho="'.wc_get_dimension( $product_variado->get_width(), 'm').'" largo="'.wc_get_dimension( $product_variado->get_length(), 'm').'" peso="'.wc_get_weight( $peso , 'kg' ).'" valor=" 0" cant="1" />';78 $xml .= '<paquete alto="'.wc_get_dimension( $product_variado->get_height(), 'm').'" ancho="'.wc_get_dimension( $product_variado->get_width(), 'm').'" largo="'.wc_get_dimension( $product_variado->get_length(), 'm').'" peso="'.wc_get_weight( $peso , 'kg' ).'" valor="'.$envio[4].'" cant="1" />'; 79 79 } 80 80 } -
woo-oca/trunk/oca-utilities.php
r1778731 r1785038 8 8 // ========================================================================= 9 9 /** 10 * Shortcode [ sucursales_oca]11 * 12 */ 13 add_shortcode ( ' sucursales_oca' , 'woo_oca_sucursales_oca_func' );14 function woo_oca_ sucursales_oca_func( $atts, $content= NULL) {15 if($_POST[' cp']){16 $post_data = [ "CodigoPostal" => intval($_POST[' cp']) ];10 * Shortcode [rastreo_oca] 11 * 12 */ 13 add_shortcode ( 'rastreo_oca' , 'woo_oca_rastreo_oca_func' ); 14 function woo_oca_rastreo_oca_func( $atts, $content= NULL) { 15 if($_POST['id']){ 16 $post_data = [ "CodigoPostal" => intval($_POST['id']) ]; 17 17 $url = 'http://webservice.oca.com.ar/epak_tracking/Oep_TrackEPak.asmx/GetCentrosImposicionConServiciosByCP'; 18 18 $response = wp_remote_get( $url, array( … … 75 75 76 76 77 78 79 // ========================================================================= 80 /** 81 * Shortcode [sucursales_oca] 82 * 83 */ 84 add_shortcode ( 'sucursales_oca' , 'woo_oca_sucursales_oca_func' ); 85 function woo_oca_sucursales_oca_func( $atts, $content= NULL) { 86 if($_POST['cp']){ 87 $post_data = [ "CodigoPostal" => intval($_POST['cp']) ]; 88 $url = 'http://webservice.oca.com.ar/epak_tracking/Oep_TrackEPak.asmx/GetCentrosImposicionConServiciosByCP'; 89 $response = wp_remote_get( $url, array( 90 'method' => 'GET', 91 'timeout' => 45, 92 'redirection' => 5, 93 'httpversion' => '1.0', 94 'blocking' => true, 95 'headers' => array(), 96 'body' => $post_data, 97 'cookies' => array() 98 ) 99 ); 100 $response = $response['http_response']->get_response_object()->body; 101 $dom = new DOMDocument(); 102 @$dom->loadXML($response); 103 $xpath = new DOMXpath($dom); 104 105 $c_imp = array(); 106 foreach (@$xpath->query("//CentrosDeImposicion/Centro") as $ci) 107 { 108 $c_imp[] = array( 'idCentroImposicion' => $ci->getElementsByTagName('IdCentroImposicion')->item(0)->nodeValue, 109 'Sucursal' => $ci->getElementsByTagName('Sucursal')->item(0)->nodeValue, 110 'Sigla' => $ci->getElementsByTagName('Sigla')->item(0)->nodeValue, 111 'Sucursal' => $ci->getElementsByTagName('Sucursal')->item(0)->nodeValue, 112 'Calle' => $ci->getElementsByTagName('Calle')->item(0)->nodeValue, 113 'Numero' => $ci->getElementsByTagName('Numero')->item(0)->nodeValue, 114 'Localidad' => $ci->getElementsByTagName('Localidad')->item(0)->nodeValue, 115 'Provincia' => $ci->getElementsByTagName('Provincia')->item(0)->nodeValue, 116 'Telefono' => $ci->getElementsByTagName('Telefono')->item(0)->nodeValue, 117 'CodigoPostal' => $ci->getElementsByTagName('CodigoPostal')->item(0)->nodeValue 118 ); 119 } 120 ob_start(); 121 echo '<table>'; 122 echo '<tr> 123 <th>ID</th> 124 <th>Nombre</th> 125 <th>Calle</th> 126 <th>Número</th> 127 <th>Localidad</th> 128 <th>Teléfono</th> 129 <th>CP</th> 130 </tr>'; 131 foreach($c_imp as $centro){ 132 echo '<tr> 133 <td>'.$centro['idCentroImposicion'].'</td> 134 <td>'.$centro['Sucursal'].'</td> 135 <td>'.$centro['Calle'].'</td> 136 <td>'.$centro['Numero'].'</td> 137 <td>'.$centro['Localidad'].'</td> 138 <td>'.$centro['Telefono'].'</td> 139 <td>'.$centro['CodigoPostal'].'</td> 140 </tr>'; 141 } 142 echo '</table>'; 143 return ob_get_clean(); 144 } 145 } 146 147 77 148 // ========================================================================= 78 149 /** … … 162 233 if ($chosen_shipping[0] === 'oca' && ($chosen_shipping[1] === 'pas' || $chosen_shipping[1] === 'sas')) { 163 234 echo "<h4>Selecciona la sucursal de OCA donde quieres recibir tu compra</h4>"; 164 $centros = woo_oca_obtener_centros_oca(WC()->customer->get_shipping_postcode() );235 $centros = woo_oca_obtener_centros_oca(WC()->customer->get_shipping_postcode(), $chosen_shipping[5] ); 165 236 echo '<select id="SucursalesOcaDestino" style="margin-bottom:15px" onchange="cambiar_suc(this.value)" >'; 166 237 echo '<option value="">Seleccionar</option>'; … … 182 253 * 183 254 */ 184 function woo_oca_obtener_centros_oca($cp ){255 function woo_oca_obtener_centros_oca($cp, $contrareembolso){ 185 256 $post_data = [ "CodigoPostal" => intval($cp) ]; 186 257 $url = 'http://webservice.oca.com.ar/epak_tracking/Oep_TrackEPak.asmx/GetCentrosImposicionConServiciosByCP'; … … 202 273 203 274 $c_imp = array(); 204 foreach (@$xpath->query("//CentrosDeImposicion/Centro") as $ci) 205 { 206 $c_imp[] = array( 'idCentroImposicion' => $ci->getElementsByTagName('IdCentroImposicion')->item(0)->nodeValue, 207 'Sucursal' => $ci->getElementsByTagName('Sucursal')->item(0)->nodeValue, 208 'Sigla' => $ci->getElementsByTagName('Sigla')->item(0)->nodeValue, 209 'Sucursal' => $ci->getElementsByTagName('Sucursal')->item(0)->nodeValue, 210 'Calle' => $ci->getElementsByTagName('Calle')->item(0)->nodeValue, 211 'Numero' => $ci->getElementsByTagName('Numero')->item(0)->nodeValue, 212 'Localidad' => $ci->getElementsByTagName('Localidad')->item(0)->nodeValue, 213 'Provincia' => $ci->getElementsByTagName('Provincia')->item(0)->nodeValue, 214 'Telefono' => $ci->getElementsByTagName('Telefono')->item(0)->nodeValue, 215 'CodigoPostal' => $ci->getElementsByTagName('CodigoPostal')->item(0)->nodeValue 216 ); 275 if($contrareembolso === 'yes'){ 276 foreach (@$xpath->query("//CentrosDeImposicion/Centro") as $ci) 277 { 278 if( $ci->getElementsByTagName('TipoAgencia')->item(0)->nodeValue === 'Sucursal OCA'){ 279 $c_imp[] = array( 'idCentroImposicion' => $ci->getElementsByTagName('IdCentroImposicion')->item(0)->nodeValue, 280 'Sucursal' => $ci->getElementsByTagName('Sucursal')->item(0)->nodeValue, 281 'Sigla' => $ci->getElementsByTagName('Sigla')->item(0)->nodeValue, 282 'Sucursal' => $ci->getElementsByTagName('Sucursal')->item(0)->nodeValue, 283 'Calle' => $ci->getElementsByTagName('Calle')->item(0)->nodeValue, 284 'Numero' => $ci->getElementsByTagName('Numero')->item(0)->nodeValue, 285 'Localidad' => $ci->getElementsByTagName('Localidad')->item(0)->nodeValue, 286 'Provincia' => $ci->getElementsByTagName('Provincia')->item(0)->nodeValue, 287 'Telefono' => $ci->getElementsByTagName('Telefono')->item(0)->nodeValue, 288 'CodigoPostal' => $ci->getElementsByTagName('CodigoPostal')->item(0)->nodeValue 289 ); 290 } 291 } 292 }else{ 293 foreach (@$xpath->query("//CentrosDeImposicion/Centro") as $ci) 294 { 295 $c_imp[] = array( 'idCentroImposicion' => $ci->getElementsByTagName('IdCentroImposicion')->item(0)->nodeValue, 296 'Sucursal' => $ci->getElementsByTagName('Sucursal')->item(0)->nodeValue, 297 'Sigla' => $ci->getElementsByTagName('Sigla')->item(0)->nodeValue, 298 'Sucursal' => $ci->getElementsByTagName('Sucursal')->item(0)->nodeValue, 299 'Calle' => $ci->getElementsByTagName('Calle')->item(0)->nodeValue, 300 'Numero' => $ci->getElementsByTagName('Numero')->item(0)->nodeValue, 301 'Localidad' => $ci->getElementsByTagName('Localidad')->item(0)->nodeValue, 302 'Provincia' => $ci->getElementsByTagName('Provincia')->item(0)->nodeValue, 303 'Telefono' => $ci->getElementsByTagName('Telefono')->item(0)->nodeValue, 304 'CodigoPostal' => $ci->getElementsByTagName('CodigoPostal')->item(0)->nodeValue 305 ); 306 } 217 307 } 218 308 return $c_imp; -
woo-oca/trunk/readme.txt
r1785031 r1785038 6 6 Tested up to: 4.9 7 7 Requires PHP: 5.6 8 Stable tag: 4.38 Stable tag: 1.1 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 17 17 Suma envios a traves de OCA a tu pagina de WooCommerce a traves de la API OCA E-Pak. 18 18 19 == Instal lation ==19 == Instalation == 20 20 21 21 1. Subi los plugins a la carpeta `/wp-content/plugins/woocommerce-oca`, o instala el plugin a traves de WordPress plugins directamente. … … 39 39 Primera salida. 40 40 41 = 1.1 = 42 Reiniciar Cache de Envíos 43 41 44 == Screenshots == 42 45 … … 53 56 * Primera subida 54 57 58 = 1.1 = 59 * Sumamos posibilidad de Pago en Destino y Corregimos un bug de sucursales 60 55 61 Si necesitas ayuda podes contactarnos a traves de nuestra web de [Ecomerciar](http://ecomerciar.com/ "Ecomerciar"). -
woo-oca/trunk/woocommerce-oca.php
r1778731 r1785038 5 5 Plugin URI: http://ecomerciar.com 6 6 Description: Integración de oca para realizar envíos a través de la plataforma WooCommerce. 7 Version: 1. 07 Version: 1.1 8 8 Author: Ecomerciar 9 9 Author URI: http://ecomerciar.com
Note: See TracChangeset
for help on using the changeset viewer.