Plugin Directory

Changeset 2752559


Ignore:
Timestamp:
07/06/2022 12:04:11 PM (4 years ago)
Author:
lucascreativecode
Message:

calculo de medidas

Location:
unienvios/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • unienvios/trunk/api.php

    r2614696 r2752559  
    5050    $endpoint = $this->urlBase . '/external-integration/quotation/create';
    5151
     52    //calculo de cubagem
     53        $cubagemTotal = 0;
     54        $pesoTotal = 0;
     55
     56        $priceOrderTotal = 0;
     57
     58            $my_width = $dados['estimate_width'];
     59            $my_height = $dados['estimate_height'];
     60            $my_length = $dados['estimate_length'];
     61            $my_weight = $dados['estimate_weight'];
     62
     63            $medidas = [
     64                doubleval($my_width) * 1,
     65                doubleval($my_height) * 1,
     66                doubleval($my_length) * 1,
     67                doubleval($my_weight) * 1
     68            ];
     69
     70            $priceOrderTotal  += doubleval($item['price']) * 1;
     71
     72
     73            $pesoTotal += $medidas[3];
     74
     75            $cubagem = ($medidas[0] * $medidas[1] * $medidas[2]) / 6000;
     76            array_push($medidas, $cubagem);
     77
     78            $cubagem = $cubagem;
     79            $cubagemTotal += $cubagem;
     80       
     81
     82        $cubagemTotal = round($cubagemTotal, 4);
     83
     84        $cubagemReversa = $cubagemTotal * doubleval(6000);
     85
     86        $raizCubica = pow($cubagemReversa, 1.0 / 3.0);
     87
     88        $raizCubica = round($raizCubica, 1);
     89
     90
    5291    $body = array(
    5392      'zipcode_destiny' => $dados['zipcode_destiny'],
     
    5695      'email_recipient' => $dados['email_recipient'],
    5796      'phone_recipient' => $dados['phone_recipient'],
    58       'estimate_height' => $dados['estimate_height'],
    59       'estimate_width' => $dados['estimate_width'],
    60       'estimate_length' => $dados['estimate_length'],
    61       'estimate_weight' => $dados['estimate_weight'],
     97      'estimate_height' => $raizCubica,
     98      'estimate_width' => $raizCubica,
     99      'estimate_length' => $raizCubica,
     100      'estimate_weight' => $pesoTotal,
    62101      'order_value' => $dados['order_value'],
    63102      'address' => $dados['address'],
     
    86125
    87126    $response = wp_remote_post($endpoint, $options);
     127    echo "<pre>";
     128    var_dump($response);
     129    echo "</pre>";
    88130
    89131    if (is_wp_error($response)) {
  • unienvios/trunk/index.php

    r2642520 r2752559  
    44Plugin URI: https://unienvios.com.br/
    55Description: Plugin de Entrega
    6 Version: 1.2.1
     6Version: 1.2.2
    77Author: Unienvios
    88Author URI: https://unienvios.com.br/
     
    5959
    6060        $quotation = $api->create_quotation($dados, $dimensoes);
    61 
     61        // echo "<pre>";
     62        // var_dump($quotation);
     63        // echo "</pre>";
    6264        if ($quotation) {
    6365
     
    9294        $api = new API_UNIENVIOS('https://api.unienvios.com.br');
    9395        $order = wc_get_order($this_get_id);
     96
    9497        $cotacao = $order->get_meta('cotacao');
    9598        $cotacao_shipping_id = $order->get_meta('shipping_id');
     
    111114            'order_value' => $cotacao['order_value'],
    112115            'address' => $order->data['shipping']['address_1'],
    113             'number' => $number ? $number : "",
     116            'number' => $number ? $number : "NÃO INFORMADO",
    114117            'city' => $order->data['shipping']['city'],
    115             'neighbourhood' => $neighbourhood ? $neighbourhood : "",
     118            'neighbourhood' => $neighbourhood ? $neighbourhood : "NÃO INFORMADO",
    116119            'state' => $order->data['shipping']['state'],
    117             'complement' => "teste",
     120            'complement' => "NÃO INFORMADO",
    118121            'shipping_id' => $cotacao_shipping_id,
    119122            'token_cotacao' => $cotacao['token'],
     
    122125        ];
    123126        $quotation = $api->cadastrar_cotacao($dados);
     127        error_log('teste abaixo');
     128        error_log(json_encode($cotacao['estimate_height']));
    124129    endif;
    125130    //add message
  • unienvios/trunk/readme.txt

    r2618384 r2752559  
    55Requires at least: 4.7
    66Tested up to: 5.8
    7 Stable tag: 1.2.0
     7Stable tag: 1.2.2
    88Requires PHP: 7.2
    99License: GPLv3 or later
     
    6868
    6969* Adicionado mais informações no readme, no tópico de instalação
     70= 1.2.2 =
     71
     72* Adicionado calculo de medidas
Note: See TracChangeset for help on using the changeset viewer.