carlos__z

Reporte Personalizado

Jun 3rd, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.21 KB | None | 0 0
  1. <table class="widefat">
  2.             <thead>
  3.                 <tr>
  4.                     <th><strong>Fecha</strong></th>
  5.                     <th><strong>Mes</strong></th>
  6.                     <th><strong>Año</strong></th>
  7.                     <th><strong>Orden</strong></th>
  8.                     <th><strong>Nombre</strong></th>
  9.                     <th><strong>Apellido</strong></th>
  10.                     <th><strong>DNI</strong></th>
  11.                     <th><strong>Dirección</strong></th>
  12.                     <th><strong>Distrito</strong></th>
  13.                     <th><strong>Correo</strong></th>
  14.                     <th><strong>Teléfono</strong></th>
  15.                     <th><strong>Categoría</strong></th>
  16.                     <th><strong>ID</strong></th>
  17.                     <th><strong>SKU</strong></th>
  18.                     <th><strong>Marca</strong></th>
  19.                     <th><strong>País</strong></th>
  20.                     <th><strong>Producto</strong></th>
  21.                     <th><strong>Cantidad</strong></th>
  22.                     <th><strong>Precio Unitario</strong></th>
  23.                     <th><strong>Subtotal</strong></th>
  24.                     <th><strong>Costo de Envío</strong></th>
  25.                     <th><strong>Total</strong></th>
  26.                     <th><strong>Método de Pago</strong></th>
  27.                 </tr>
  28.             </thead>
  29.         <tbody>
  30.         <?php foreach( $ventas_panuts_orders as $order ) {
  31.            
  32.             $order_obj = wc_get_order( $order->id_orden );
  33.             $order_data = $order_obj->get_data();
  34.             $date_created  = $order_obj->get_date_created()->format ('Y-m-d g:i a');
  35.             $strtotime = strtotime($date_created);
  36.             $hora_gmt = date("Y-m-d g:i a", strtotime('-5 hours' , $strtotime));
  37.  
  38.             $order_items = $order_obj->get_items();
  39.             $i=true;
  40.             foreach( $order_items as $product ) {
  41.                 ?>
  42.                 <tr>
  43.                 <td><?php echo $hora_gmt; ?></td>
  44.                 <td><?php echo date('M',$strtotime); ?></td>
  45.                 <td><?php echo date('Y',$strtotime); ?></td>
  46.                 <td><?php echo $order->id_orden; ?></td>
  47.                 <td style="text-transform: capitalize;"><?php echo strtolower($order_obj->get_billing_first_name()); ?></td>
  48.                 <td style="text-transform: capitalize;"><?php echo strtolower($order_obj->get_billing_last_name()); ?></td>
  49.                 <td><?php echo get_post_meta( $order->id_orden, 'billing_dni', true ); ?></td>
  50.                 <td style="text-transform: capitalize;"><?php echo strtolower($order_obj->get_billing_address_1().' '.$order_obj->get_billing_address_2());?></td>
  51.                 <td><?php echo $order_obj->get_billing_city() ?></td>
  52.                 <td style="text-transform: lowercase;"><?php echo $order_obj->get_billing_email(); ?></td>
  53.                 <td><?php echo get_post_meta( $order->id_orden, 'billing_cellphone', true ); ?></td>
  54.                 <?php
  55.            
  56.                 $_product_id = wc_get_product($product->get_product_id());
  57.                
  58.                 if ($_product_id){
  59.                    
  60.                     $producto = wc_get_product($_product_id);
  61.                     $id_producto = $producto->get_id();
  62.                     $sku_producto = $producto->get_sku();
  63.                    
  64.                     $marcas = get_the_terms( $product->get_product_id(), 'pa_marca');
  65.                     $marca = $marcas[0]->name;
  66.                    
  67.                     $paises = get_the_terms( $product->get_product_id(), 'pa_pais');
  68.                     $pais = $paises[0]->name;
  69.  
  70.                     $terms = wp_get_post_terms( $product->get_product_id(), 'product_cat' );
  71.                     $product_categories = "";
  72.                     $cont = 0;
  73.                     foreach( $terms as $wp_term ){ 
  74.                         if ($cont >=1){
  75.                             break;
  76.                         }
  77.                         if ($wp_term->name == 'Ofertas'){
  78.                             break;
  79.                         }
  80.                         $product_categories .=  $wp_term->name;    
  81.                         if ( $wp_term->name != 'Gourmet' ){
  82.                             $cont++;       
  83.                         } else {
  84.                             $product_categories .=  ' - ';
  85.                         }
  86.                     }
  87.                 }
  88.                 else {
  89.                     $product_categories = '-'; 
  90.                     $id_producto = '-';
  91.                     $sku_producto = '-';
  92.                     $marca = '-';
  93.                     $pais = '-';
  94.                 }      
  95.                 ?>     
  96.                 <td><?php echo $product_categories; ?></td>
  97.                 <td><?php echo $id_producto; ?></td>
  98.                 <td><?php echo $sku_producto; ?></td>
  99.                 <td><?php echo $marca; ?></td>
  100.                 <td><?php echo $pais; ?></td>
  101.                 <td><?php echo '<p>'.$product['name'].'</p>'; ?></td>
  102.                 <td align="center"><?php echo '<p>'.$product['qty'].'</p>'; ?></td>
  103.                 <td align="center"><?php echo '<p>'.$product->get_total()/$product['qty'].'</p>'; ?></td>  
  104.                 <td align="center"><?php echo $product->get_total(); ?></td>
  105.                 <?php
  106.                 if ($i){ ?>
  107.                     <td><?php echo $order_obj->get_shipping_total(); ?></td>
  108.                     <td><?php echo wc_price($order->orden_total); ?></td> <!-- total de orden -->
  109.                     <td><?php echo $order_obj->get_payment_method_title(); ?></td>
  110.                     <?php $i=false; } ?>
  111.                     </tr>
  112.             <?php }
  113.         } ?>
  114.         </tbody>
  115.         </table>
Advertisement
Add Comment
Please, Sign In to add comment