{"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\n

V\u00fdsledek v e-mailu vypad\u00e1 takto:<\/p>\n\n\n\n

\"\"<\/a><\/figure>\n\n\n\n

V p\u0159\u00edpad\u011b. \u017ee chcete editovat to, jak v\u00fdpis vypad\u00e1, mus\u00edte upravit soubor email-customer-details.php v \u0161ablon\u011b e-mailu.<\/p>\n\n\n\n

Informace pro z\u00e1kazn\u00edka jsou ide\u00e1ln\u00ed pro zobrazov\u00e1n\u00ed dat, kter\u00e9 nejsou na prvn\u00ed pohled viditeln\u00e1 a p\u0159itom je m\u016f\u017ee administr\u00e1tor obchodu pot\u0159ebovat.<\/p>\n","protected":false},"excerpt":{"rendered":"

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. 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. Pro snippet si vytvo\u0159\u00edme<\/p>\n","protected":false},"author":1,"featured_media":5600,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[29],"tags":[],"class_list":["post-6582","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-woocommerce-snippety"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6582"}],"collection":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/comments?post=6582"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6582\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/5600"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=6582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=6582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=6582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}