well, maybe this answer will help someone else in the future, i figure it out, i leave the function here just in case
// Muestra los custom fields en el carrito
add_filter( 'woocommerce_get_item_data', 'super_custom_field', 10, 2 );
function super_custom_field( $cart_data, $cart_item )
{
$items_super = array();
if( !empty( $cart_data ) )
$custom_items = $cart_data;
// Los busca desde el id
$product_id = $cart_item['product_id'];
$supermercado_1 = get_field('super_1',7);
$supermercado_2 = get_field('super_2',7);
$supermercado_3 = get_field('super_3',7);
if( $precio_1 = get_post_meta( $product_id, 'precio_1', true ))
if( $precio_2 = get_post_meta( $product_id, 'precio_2', true ))
if( $precio_3 = get_post_meta( $product_id, 'precio_3', true ))
$items_super[] = array(
'name' => __( 'Precios en supermercados', 'woocommerce'),
'display' => '<div>
<p class="super1 supermercados"><strong>' . ($supermercado_1). '</strong> <span>$' . ($precio_1). '</span></p>
<p class="super2 supermercados"><strong>' . ($supermercado_2). '</strong> <span>$' . ($precio_2). '</span></p>
<p class="super3 supermercados"><strong>' . ($supermercado_3). '</strong> <span>$' . ($precio_3). '</span></p>
</div>',
);
return $items_super;
}
//Suma los custom field de precio 1
//Elige el lugar donde lo muestra
add_filter( 'woocommerce_after_cart_contents', 'suma_precio_1', 10, 2 );
//este es despues del carro antes del checkout
add_action( 'woocommerce_cart_totals_before_shipping', 'suma_precio_1', 20 );
//este es en el checkout
add_action( 'woocommerce_review_order_before_shipping', 'suma_precio_1', 20 );
function suma_precio_1() {
$total_1 = 0;
$supermercado_1 = get_field('super_1',7);
// Busca en el loop del carro el cutom field en cada producto y los suma y multiplica por la cantidad
foreach( WC()->cart->get_cart() as $cart_item ){
$precio_super_1 = (float) get_post_meta( $cart_item['product_id'], 'precio_1', true );
$total_1 += $precio_super_1 * $cart_item['quantity'];
}
if( $total_1 > 0 ){
// The Output
echo ' <tr class="super1">
<td colspan="5"><p><strong>' .$supermercado_1. '</strong></td> <td colspan="" style="text-align:right;"><span>$' . number_format($total_1, 2) . '</span></p></td>
</tr>';
}
}
//Suma los custom field de precio 1
//Elige el lugar donde lo muestra
add_filter( 'woocommerce_after_cart_contents', 'suma_precio_2', 10, 2 );
//este es despues del carro antes del checkout
add_action( 'woocommerce_cart_totals_before_shipping', 'suma_precio_2', 20 );
//este es en el checkout
add_action( 'woocommerce_review_order_before_shipping', 'suma_precio_2', 20 );
function suma_precio_2() {
$total_2 = 0;
$supermercado_2 = get_field('super_2', 7);
// Busca en el loop del carro el cutom field en cada producto y los suma y multiplica por la cantidad
foreach( WC()->cart->get_cart() as $cart_item ){
$precio_super_2 = (float) get_post_meta( $cart_item['product_id'], 'precio_2', true );
$total_2 += $precio_super_2 * $cart_item['quantity'];
}
if( $total_2 > 0 ){
// The Output
echo ' <tr class="super2">
<td colspan="5"><p><strong>' .$supermercado_2. '</strong></td> <td colspan="" style="text-align:right;"><span>$' . number_format($total_2, 2) . '</span></p></td>
</tr>';
}
}
//Suma los custom field de precio 1
//Elige el lugar donde lo muestra
add_filter( 'woocommerce_after_cart_contents', 'suma_precio_3', 10, 2 );
//este es despues del carro antes del checkout
add_action( 'woocommerce_cart_totals_before_shipping', 'suma_precio_3', 20 );
//este es en el checkout
add_action( 'woocommerce_review_order_before_shipping', 'suma_precio_3', 20 );
function suma_precio_3() {
$total_3 = 0;
$supermercado_3 = get_field('super_3', 7);
// Busca en el loop del carro el custom field en cada producto y los suma y multiplica por la cantidad
foreach( WC()->cart->get_cart() as $cart_item ){
$precio_super_3 = (float) get_post_meta( $cart_item['product_id'], 'precio_3', true );
$total_3 += $precio_super_3 * $cart_item['quantity'];
}
if( $total_3 > 0 ){
// The Output
echo ' <tr class="super3">
<td colspan="5"><p><strong>' .$supermercado_3. '</strong></td> <td colspan="" style="text-align:right;"><span>$' . number_format($total_3, 2) . '</span></p></td>
</tr>';
}
}