PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Sort Meta Key - _price_peso - Help please

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

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

Just  add  this  meta  field  to  the  table.  And if there are products with this meta field, everything will work correctly.

yes is working properly according the function but whe I try to sort it by des or asc value it gives error as the photo.

so I couldn't sort by high to low

Hello

Of course, if this value is not in the database, then there is nothing to sort.