<\/a><\/figure>\n\n\n\nProto\u017ee je stejn\u00fd pro ka\u017ed\u00fd e-mail, budeme jej m\u011bnit dynamicky.<\/p>\n\n\n\n
\u0158ekn\u011bme, \u017ee m\u00e1te na e-shopu r\u016fzn\u00e9 u\u017eivatelsk\u00e9 \u00farovn\u011b a chcete pro n\u011b personalizovat text v pati\u010dce. Obdobn\u011b to m\u016f\u017ee fungovat, i kdy\u017e budete m\u00edt tzv. multivendor e-shop.<\/p>\n\n\n\n
Pou\u017eijeme filter woocommerce_email_footer_text a pomoc\u00ed z\u00edskan\u00e9 role, uprav\u00edme text v pati\u010dce e-mailu. <\/p>\n\n\n\n
Bohu\u017eel, tento filter m\u00e1 probl\u00e9m v tom, \u017ee p\u0159ij\u00edm\u00e1 pouze hodnotu nastaven\u00ed. Proto mus\u00edme nejprve vytvo\u0159it vlastn\u00ed glob\u00e1ln\u00ed prom\u011bnou, do n\u00ed\u017e vlo\u017e\u00edme id objedn\u00e1vky:<\/p>\n\n\n\n
add_action( 'woocommerce_email_before_order_table', 'musilda_email_order_id_as_a_global', 1, 1 );\nfunction musilda_email_order_id_as_a_global( $order ){\n $GLOBALS['order_id_str'] = $order->get_id();\n}<\/code><\/pre>\n\n\n\nT\u00edm jsme z\u00edskali p\u0159\u00edstup k id objedn\u00e1vky i v p\u0159\u00edslu\u0161n\u00e9m filteru a m\u016f\u017eeme napsat funkci:<\/p>\n\n\n\n
add_action( 'woocommerce_email_footer_text', 'custom_email_footer_text', 10, 1 );\nfunction custom_email_footer_text( $footer_text ){\n\n \tif ( !empty( $GLOBALS['order_id_str'] ) ) {\n\n\t\t$order_id = (int)$GLOBALS['order_id_str'];\n\t\t$order = wc_get_order( $order_id );\n\t\t$customer_id = $order->get_customer_id();\n\t\t$user_data = get_userdata( $customer_id );\n \tif ( in_array( 'wholesale_customer', $user_data->roles ) ) {\n\t\t\t$footer_text = __( 'Text v pati\u010dce e-mailu pro odb\u011bratele', 'musilda' );\n\t\t}\n\n\t}\n\n return $footer_text;\n\n}<\/code><\/pre>\n\n\n\nD\u00edky u\u017eivatelsk\u00e9 roli se pak bude zobrazovat v pati\u010dce odli\u0161n\u00fd text.<\/p>\n","protected":false},"excerpt":{"rendered":"
WooCommerce obsahuje nastaven\u00ed, kter\u00e9 umo\u017e\u0148uje vlo\u017eit do pati\u010dky ka\u017ed\u00e9ho e-mailu vlastn\u00ed text. Ten je spole\u010dn\u00fd pro v\u0161echny e-maily. Pomoc\u00ed k\u00f3du budeme upravovat text podle toho, jakou u\u017eivatelskou roli m\u00e1 u\u017eivatel. WooCommerce m\u00e1 vlastn\u00ed nastaven\u00ed pro v\u0161echny e-maily: Proto\u017ee je stejn\u00fd pro ka\u017ed\u00fd e-mail, budeme jej m\u011bnit dynamicky. \u0158ekn\u011bme, \u017ee m\u00e1te na e-shopu r\u016fzn\u00e9 u\u017eivatelsk\u00e9 \u00farovn\u011b<\/p>\n","protected":false},"author":1,"featured_media":5600,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-6592","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\/6592"}],"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=6592"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6592\/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=6592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=6592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=6592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}