Skip to content

Instantly share code, notes, and snippets.

@iamsathyaseelan
Created June 23, 2020 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamsathyaseelan/4aa4793ed139de33a25cec98389e2e09 to your computer and use it in GitHub Desktop.
Save iamsathyaseelan/4aa4793ed139de33a25cec98389e2e09 to your computer and use it in GitHub Desktop.
view order meta shortcodes Email customizer plus
<?php
add_filter('woocommerce_email_customizer_plus_additional_short_codes_list',function($additional_short_codes){
$order_id = 803;
$order_meta_keys = get_post_custom_keys($order_id);
if (!empty($order_meta_keys)) {
$order_meta_values = get_post_meta($order_id);
foreach ($order_meta_keys as $order_meta_key) {
if (isset($order_meta_values[$order_meta_key]) && isset($order_meta_values[$order_meta_key][0])) {
$order_meta_key_for_short_code = str_replace(' ', '_', $order_meta_key);
$key = 'order_meta.'.$order_meta_key_for_short_code;
if (is_string($order_meta_values[$order_meta_key][0])) {
$additional_short_codes[$key] = $order_meta_values[$order_meta_key][0];
}
}
}
}
return $additional_short_codes;
},10,3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment