{"id":5401,"date":"2020-01-02T05:54:04","date_gmt":"2020-01-02T05:54:04","guid":{"rendered":"https:\/\/musilda.cz\/?p=5401"},"modified":"2020-01-02T05:54:04","modified_gmt":"2020-01-02T05:54:04","slug":"jak-vytvorit-vlastni-stav-objednavky-ve-woocommerce","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-vytvorit-vlastni-stav-objednavky-ve-woocommerce\/","title":{"rendered":"Jak vytvo\u0159it vlastn\u00ed stav objedn\u00e1vky ve WooCommerce"},"content":{"rendered":"\n

WooCommerce p\u0159i vytv\u00e1\u0159en\u00ed objedn\u00e1vky, pou\u017e\u00edv\u00e1 n\u011bkolik v\u00fdchoz\u00edch stav\u016f, kter\u00e9 pou\u017eije pro ozna\u010den\u00ed stavu, v kter\u00e9m se objedn\u00e1vka nach\u00e1z\u00ed. Tyto stavy jdou pom\u011brn\u011b jednodu\u0161e roz\u0161\u00ed\u0159it.<\/p>\n\n\n\n

Objedn\u00e1vka je technicky post type. To znamen\u00e1, \u017ee m\u00e1 stejn\u00e9 prvky, jako post a pro stavy objedn\u00e1vek se pou\u017e\u00edv\u00e1 post status. Ka\u017ed\u00fd post m\u00e1 stavy draft, publish atd. WordPress umo\u017e\u0148uje registrovat vlastn\u00ed stavy pomoc\u00ed register_post_status<\/a>.<\/p>\n\n\n\n

Toho vyu\u017e\u00edv\u00e1 i WooCommerce a roz\u0161i\u0159uje stavy post\u016f o:<\/p>\n\n\n\n

Pending payment<\/strong> (\u010dek\u00e1 na platbu) – p\u0159i vytvo\u0159en\u00ed objedn\u00e1vky, kdy\u017e je\u0161t\u011b nebyla zpracov\u00e1na platebn\u00ed metoda.<\/p>\n\n\n\n

On hold<\/strong> (\u010dek\u00e1 na vy\u0159\u00edzen\u00ed) – vytvo\u0159en\u00e1 objedn\u00e1vka, jsou t\u0159eba dal\u0161\u00ed kroky, typicky se jedn\u00e1 o bankovn\u00ed p\u0159evod, kdy \u010dek\u00e1te na pen\u00edze, aby jste poslali objedn\u00e1vku z\u00e1kazn\u00edkovi.<\/p>\n\n\n\n

Processing<\/strong> (zpracov\u00e1v\u00e1 se) – stav, kdy je objedn\u00e1vka ji\u017e ve zpracov\u00e1v\u00e1n\u00ed, ale nen\u00ed dokon\u010den\u00e1. Pou\u017e\u00edv\u00e1m pro platbu kartou, nebo p\u0159i odesl\u00e1n\u00ed z\u00e1silky na dob\u00edrku. <\/p>\n\n\n\n

Completed<\/strong> (dokon\u010deno) – dokon\u010den\u00e1 objedn\u00e1vka.<\/p>\n\n\n\n

Cancelled<\/strong> (zru\u0161eno) – \u00fasp\u011b\u0161n\u00e1 objedn\u00e1vka, kter\u00e1 byla zru\u0161ena.<\/p>\n\n\n\n

Failed<\/strong> (selhalo) – ne\u00fasp\u011b\u0161n\u00e1 objedn\u00e1vka, v\u011bt\u0161inou se jedn\u00e1 o technickou chybu, nebo zru\u0161en\u00ed platby na platebn\u00ed br\u00e1ny.<\/p>\n\n\n\n

Refunded<\/strong> (vr\u00e1ceno) – stav objedn\u00e1vky po vr\u00e1cen\u00ed. <\/p>\n\n\n\n

O stavech objedn\u00e1vky<\/a> jsem psal ji\u017e d\u0159\u00edve v n\u00e1vodu k WooCommerce<\/a><\/p>\n\n\n\n

Registrace stav\u016f objedn\u00e1vky<\/h2>\n\n\n\n

WooCommerce registruje vlastn\u00ed stavy post\u016f v souboru wc-class-post-types.php v metod\u011b register_post_types. Zde je nadefinov\u00e1no pole pol\u00ed, kter\u00e9 jsou pak proch\u00e1zeny a pou\u017e\u00edv\u00e1ny jako argumenty pro register_post_status. <\/p>\n\n\n\n

Cel\u00e9 nadefinovan\u00e9 pole m\u00e1te k dispozici pomoc\u00ed filtru woocommerce_register_shop_order_post_statuses . <\/p>\n\n\n\n

1. Definov\u00e1n\u00ed stavu objedn\u00e1vky<\/h3>\n\n\n\n

Pro definici pot\u0159ebujete zadat:<\/p>\n\n\n\n