carlos__z

Reporte Personalizado Prod

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