Quote from ANDERSON_G on December 11, 2024, 18:30
Hello. please i have custom keta key and i need to be able to sort this value in the WOOT table.
_price_peso
function is:
add_action('woot_meta_data_cell', function($value, $meta_data, $post_id, $table_id) {
if (isset($meta_data['meta_key']) && $meta_data['meta_key'] === '_price_peso' && $table_id === 28) {
$product_price = get_post_meta($post_id, '_price', true);
if (!$product_price || !is_numeric($product_price)) {
return $value; // Salir si no hay un precio válido
}
$product_categories = wp_get_post_terms($post_id, 'product_cat', array('fields' => 'ids'));
$group_1 = [775, 771, 861];
$group_2 = [989];
if (array_intersect($product_categories, $group_1)) {
$price = round((((floatval($product_price)/1.15)-15)/1.20), 2);
} elseif (array_intersect($product_categories, $group_2)) {
$price = round((floatval($product_price))/1.25, 2);
} else {
$price = round(((floatval($product_price)/1.15)/1.20), 2);
}
$product = wc_get_product($post_id);
$stock = $product->get_stock_quantity();
if (!$stock || !is_numeric($stock)) {
$stock = 0;
}
$sumpr = number_format($stock * $price, 2, ',', ' ');
$value = "$" . $sumpr;
}
return $value;
}, 10, 4);
issue screenshot:

Hello. please i have custom keta key and i need to be able to sort this value in the WOOT table.
_price_peso
function is:
add_action('woot_meta_data_cell', function($value, $meta_data, $post_id, $table_id) {
if (isset($meta_data['meta_key']) && $meta_data['meta_key'] === '_price_peso' && $table_id === 28) {
$product_price = get_post_meta($post_id, '_price', true);
if (!$product_price || !is_numeric($product_price)) {
return $value; // Salir si no hay un precio válido
}
$product_categories = wp_get_post_terms($post_id, 'product_cat', array('fields' => 'ids'));
$group_1 = [775, 771, 861];
$group_2 = [989];
if (array_intersect($product_categories, $group_1)) {
$price = round((((floatval($product_price)/1.15)-15)/1.20), 2);
} elseif (array_intersect($product_categories, $group_2)) {
$price = round((floatval($product_price))/1.25, 2);
} else {
$price = round(((floatval($product_price)/1.15)/1.20), 2);
}
$product = wc_get_product($post_id);
$stock = $product->get_stock_quantity();
if (!$stock || !is_numeric($stock)) {
$stock = 0;
}
$sumpr = number_format($stock * $price, 2, ',', ' ');
$value ="$" . $sumpr;
}
return $value;
}, 10, 4);
issue screenshot:
