{"id":6428,"date":"2021-10-27T10:59:00","date_gmt":"2021-10-27T10:59:00","guid":{"rendered":"https:\/\/musilda.cz\/?p=6428"},"modified":"2021-10-27T10:59:00","modified_gmt":"2021-10-27T10:59:00","slug":"jak-zablokovat-nakup-pro-problematickeho-zakaznika-ve-woocommerce","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-zablokovat-nakup-pro-problematickeho-zakaznika-ve-woocommerce\/","title":{"rendered":"Jak zablokovat n\u00e1kup pro problematick\u00e9ho z\u00e1kazn\u00edka ve WooCommerce"},"content":{"rendered":"\n

N\u011bkte\u0159\u00ed z\u00e1kazn\u00edci si objednaj\u00ed zbo\u017e\u00ed na dob\u00edrku a nep\u0159evezmou jej. Pokud v\u00e1m cht\u011bj\u00ed \u0161kodit, nebo jim nechcete pos\u00edlat dal\u0161\u00ed z\u00e1silky, pom\u016f\u017ee v\u00e1m jednoduch\u00fd snippet, kter\u00fd je zablokuje. <\/p>\n\n\n\n

Postup je n\u00e1sleduj\u00edc\u00ed – m\u00e1te pole e-mail\u016f, kter\u00e9 chcete banovat a p\u0159i zpracov\u00e1n\u00ed pokladny je zkontrolujete a pokud tak e-mail bude, nedokon\u010d\u00edte objedn\u00e1vku. Ta se ani nevytvo\u0159\u00ed, tak\u017ee se v\u00e1m nezkresluj\u00ed statistiky, negeneruj\u00ed faktury a podobn\u011b.<\/p>\n\n\n\n

Snippet je jednoduch\u00fd:<\/h2>\n\n\n\n
add_filter( 'woocommerce_before_checkout_process', 'disable_order_for_banned_user' );\nfunction disable_order_for_banned_user() {\n\u00a0 \u00a0 $banned_emails = array( 'musilekv@seznam.cz', 'musilda@musilda.cz' );\u00a0 \u00a0 \u00a0 \u00a0\n    if ( !empty( $_POST['billing_email'] ) && in_array( $_POST['billing_email'], $banned_emails ) ) {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\n         throw new Exception( __( 'Velice se omlouv\u00e1me, ale m\u00e1me technick\u00e9 probl\u00e9my, pokud chcete objednat, kontaktujte n\u00e1s telefonicky.', 'musilda' ) );\n\u00a0 \u00a0 }\n}<\/code><\/pre>\n\n\n\n

V\u00fdsledek:<\/h2>\n\n\n\n
\"\"<\/a><\/figure>\n\n\n\n

Tento postup jsem zvolil ze dvou d\u016fvod\u016f – kontrolovat zadan\u00fd e-mail pomoc\u00ed js nen\u00ed na 100% jist\u00e9 a kdy\u017e z\u00e1kazn\u00edkovi uk\u00e1\u017ei technickou chybu, tak si nem\u016f\u017ee st\u011b\u017eovat, \u017ee banuji konkr\u00e9tn\u011b jeho.<\/p>\n","protected":false},"excerpt":{"rendered":"

N\u011bkte\u0159\u00ed z\u00e1kazn\u00edci si objednaj\u00ed zbo\u017e\u00ed na dob\u00edrku a nep\u0159evezmou jej. Pokud v\u00e1m cht\u011bj\u00ed \u0161kodit, nebo jim nechcete pos\u00edlat dal\u0161\u00ed z\u00e1silky, pom\u016f\u017ee v\u00e1m jednoduch\u00fd snippet, kter\u00fd je zablokuje. Postup je n\u00e1sleduj\u00edc\u00ed – m\u00e1te pole e-mail\u016f, kter\u00e9 chcete banovat a p\u0159i zpracov\u00e1n\u00ed pokladny je zkontrolujete a pokud tak e-mail bude, nedokon\u010d\u00edte objedn\u00e1vku. Ta se ani nevytvo\u0159\u00ed, tak\u017ee<\/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-6428","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\/6428"}],"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=6428"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6428\/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=6428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=6428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=6428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}