79313057

Date: 2024-12-28 01:37:04
Score: 2
Natty:
Report link

Thank you for posting this, it helped me a lot. Just like you, I needed to retrieve EPO data from my orders, though, my structure was more complex than just one field (I have around 20 different options). I did not use it as a function because it did not work but modified your code with unserialize:

Note: EPO is now stored in wp_woocommerce_order_itemmeta table and works with key pairs

$output = ''; 
$epos = unserialize($yourmetavalue);  
if (is_array($epos) ){
    foreach ($epos as $key => $epo) {
        if ($epo && is_array($epo)){
            $output .= '' . $epo['name'] .': '. $epo['value'] .'<br>';
        }
    }
}
echo $output;

Since I wanted to exclude certain values (like comments) and have links for EPO files uploaded by the clinets this is my actual code:

$output = ''; 
$epos = unserialize($epodata); 
    if (is_array($epos) ){
        foreach ($epos as $key => $epo) {
            if ($epo && is_array($epo) && $epo['name'] != "Commentaire"){
                if (strpos($epo['value'], 'http') === 0) {
                    $epo['value'] = "<a target='_blank' href='".$epo['value']."'>See file</a>";
                }
                $output .= '' . $epo['name'] .': '. $epo['value'] .'<br>';
            }
        }
    }
echo $output;

Be aware that I was unable to make your code work, (skill issue). The reason I am posting here is because I have never seen anyone try to extract EPO data from the DB other than you.

Hope it can help others.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (0.5): I need
  • Blacklisted phrase (1): did not work
  • Blacklisted phrase (1): helped me a lot
  • Whitelisted phrase (-1): Hope it can help
  • Long answer (-1):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: François