Как насчет:
max(zip(stats.keys(), stats.values()), key=lambda t : t[1])[0]
Вот пример, который покажет вам, как добавить новые заполнители для уведомлений по электронной почте. Subject:
// Only for woocommerce versions 3.2 + (up to 3.2)
add_filter( 'woocommerce_email_format_string' , 'filter_email_format_string', 20, 2 );
function filter_email_format_string( $string, $email ) {
// Get the instance of the WC_Order object
$order = $email->object;
// Additional wanted placeholders in the array of find / relace pairs
$additional_placeholders = array(
'{custom_one}' => __('my replacement one','woocommerce'),
'{shipping_city}' => $order->get_shipping_city(),
'{yudu_pw}' => get_post_meta( $order->id, 'yudu_pw', true ), // <=== HERE
);
// return the clean string with new replacements
return str_replace( array_keys( $additional_placeholders ), array_values( $additional_placeholders ), $string );
}
Код идет в файле function.php вашей активной дочерней темы (или активной теме ). Проверено и работает только для версии Woocommerce версии 3.2 и выше ...