WooCommerce-Produkt-Meta-Keys global zu allen Shortcodes hinzufügen
Um WooCommerce-Produkt-Meta-Keys global zu allen WOOT-Shortcodes hinzuzufügen, verwenden Sie den Hook woot_profile_extend.
Beispiel: Fügen Sie in die Datei functions.php des aktuellen WordPress-Themes folgenden Code ein
add_action('woot_profile_extend', function($profile, $action_name) {
if ($action_name === 'woot_woocommerce_tables') {
$meta_key = 'my_global_column';//important!
$meta_data = [
'title' => WOOT_Vocabulary::get('My meta column'),
'meta_key' => $meta_key,
'meta_type' => 'text', //text, number, calendar
];
$profile[$meta_key] = woot()->columns->meta->assemble_meta_for_system($meta_data);
}
return $profile;
}, 10, 2);Ersetzen Sie im Code in der Variable $meta_key den Meta-Key durch Ihren eigenen und ändern Sie den Spaltentitel (My meta column).
Beachten Sie die Metadatentypen:
- text
- number
- calendar