{"id":6582,"date":"2022-01-07T09:52:00","date_gmt":"2022-01-07T09:52:00","guid":{"rendered":"https:\/\/musilda.cz\/?p=6582"},"modified":"2022-01-07T09:52:00","modified_gmt":"2022-01-07T09:52:00","slug":"zobrazeni-informaci-o-uzivateli-v-e-mailu-pro-administratora-woocommerce","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/zobrazeni-informaci-o-uzivateli-v-e-mailu-pro-administratora-woocommerce\/","title":{"rendered":"Zobrazen\u00ed informac\u00ed o u\u017eivateli v e-mailu pro administr\u00e1tora WooCommerce"},"content":{"rendered":"\n
WooCommerce m\u00e1 v e-mailu dv\u011b m\u00edsta, kter\u00e9 lze vyu\u017e\u00edt pro zobrazen\u00ed dodate\u010dn\u00fdch informac\u00ed. Jedn\u00edm z nich je tzv. customer details. <\/p>\n\n\n\n
D\u0159\u00edve se pou\u017e\u00edval po zobrazen\u00ed pozn\u00e1mky, e-mail a telefonu z\u00e1kazn\u00edka, ale od verze 3.2 to tak ji\u017e nen\u00ed. Aktu\u00e1ln\u011b nezobrazuje nic, ale mi jej m\u016f\u017eeme vyu\u017e\u00edt pro dopln\u011bn\u00ed informac\u00ed do e-mailu. <\/p>\n\n\n\n
Pro snippet si vytvo\u0159\u00edme situaci, kdy m\u00e1te na e-shopu n\u011bjak\u00fd v\u011brnostn\u00ed program a chcete m\u00edt informaci o mno\u017estv\u00ed, kter\u00e9 m\u00e1 z\u00e1kazn\u00edk k dispozici. <\/p>\n\n\n\n
WooCommerce obsahuje filter, kter\u00e1 se jmenuje woocommerce_email_customer_details_fields a ten n\u00e1m v\u00fdborn\u011b poslou\u017e\u00ed. <\/p>\n\n\n\n
Vytvo\u0159\u00edme si funkci:<\/p>\n\n\n\n
add_filter( 'woocommerce_email_customer_details_fields', 'musilda_emial_display_customer_data', 10, 3 );\nfunction musilda_emial_display_customer_data( $fields, $sent_to_admin, $order ) {\n\n\tif ( true === $sent_to_admin ) {\n\t\t$customer_id = $order->get_customer_id();\n\t\tif ( $customer_id ) {\n\t\t\t$points = get_user_meta( $customer_id, 'points', true );\n\t\t\tif ( !empty( $points ) ) {\n\t\t\t\t$fields[] = array(\n\t\t 'label' => __( 'Po\u010det v\u011brnostn\u00edch bod\u016f z\u00e1kazn\u00edka', 'musilda' ),\n\t\t 'value' => $points\n\t );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn $fields;\n}\n<\/code><\/pre>\n\n\n\nV\u00fdsledek v e-mailu vypad\u00e1 takto:<\/p>\n\n\n\n