Changeset 2642517
- Timestamp:
- 12/10/2021 04:18:20 PM (4 years ago)
- Location:
- unienvios/trunk
- Files:
-
- 2 edited
-
ClassUnienvios.php (modified) (2 diffs)
-
index.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
unienvios/trunk/ClassUnienvios.php
r2614696 r2642517 67 67 public function calculate_shipping($package = null) 68 68 { 69 69 70 global $woocommerce; 70 71 $items = $woocommerce->cart->get_cart(); … … 78 79 $count = 0; 79 80 //LOOP ALL THE PRODUCTS IN THE CART 81 $cubagemTotal = 0; 82 $pesoTotal = 0; 80 83 foreach ($items as $item => $values) { 81 84 $count += 1; 82 85 $_product = wc_get_product($values['data']->get_id()); 83 //GET GET PRODUCT M3 84 $dimensoes['estimate_height'] += doubleval($_product->get_height()) * $values['quantity']; 85 $dimensoes['estimate_width'] += doubleval($_product->get_width()) * $values['quantity']; 86 $dimensoes['estimate_length'] += doubleval($_product->get_length()) * $values['quantity']; 87 $dimensoes['estimate_weight'] += doubleval($_product->get_weight()) * $values['quantity']; 88 // pegar quantidade do item 86 87 $medidas = [ 88 doubleval($_product->get_height()) * intval( $values['quantity'] ), 89 doubleval($_product->get_width()) * intval( $values['quantity'] ), 90 doubleval($_product->get_length()) * intval( $values['quantity']), 91 doubleval($_product->get_weight()) * intval( $values['quantity'] ) 92 ]; 93 94 $pesoTotal += $medidas[3]; 95 96 $cubagem = ( $medidas[0] * $medidas[1] * $medidas[2] )/6000; 97 array_push($medidas, $cubagem); 98 99 $cubagem = $cubagem; 100 $cubagemTotal += $cubagem; 101 89 102 } 103 104 $cubagemTotal = round($cubagemTotal, 4); 105 106 $cubagemReversa = $cubagemTotal * doubleval(6000); 107 108 $raizCubica = pow($cubagemReversa, 1.0/3.0); 109 110 $raizCubica = round($raizCubica, 1); 111 112 $dimensoes = [ 113 'estimate_height' => $raizCubica, 114 'estimate_width' => $raizCubica, 115 'estimate_length' => $raizCubica, 116 'estimate_weight' => $pesoTotal 117 ]; 118 90 119 // wc_add_notice( __('debug: ', 'woothemes') . json_encode($dimensoes), 'error' ); 91 120 // return; 121 122 // wp_send_json($dimensoes); 92 123 93 124 $api = new API_UNIENVIOS('https://api.unienvios.com.br'); -
unienvios/trunk/index.php
r2618363 r2642517 154 154 ]; 155 155 156 156 157 $quotation = $api->create_quotation($dados, $dimensoes); 157 158
Note: See TracChangeset
for help on using the changeset viewer.