{"id":2093,"date":"2014-10-19T20:10:34","date_gmt":"2014-10-19T20:10:34","guid":{"rendered":"http:\/\/musilda.cz\/?p=2093"},"modified":"2014-10-19T20:10:34","modified_gmt":"2014-10-19T20:10:34","slug":"ulozeni-custom-fields-k-objednavce-ve-woocommerce","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/ulozeni-custom-fields-k-objednavce-ve-woocommerce\/","title":{"rendered":"Ulo\u017een\u00ed custom fields k objedn\u00e1vce ve WooCommerce"},"content":{"rendered":"
Pokud pot\u0159ebujete ulo\u017eit spole\u010dn\u011b s objedn\u00e1vkou vlastn\u00ed data, pom\u016f\u017ee v\u00e1m n\u00e1sleduj\u00ed snippet. Pomoc\u00ed n\u011bj ulo\u017e\u00edte custom field pro aktu\u00e1ln\u011b vytvo\u0159enou objedn\u00e1vku. Funkce \u0159e\u0161\u00ed pouze ulo\u017een\u00ed, ne jak data z\u00edsk\u00e1te a jak jej zobraz\u00edte v administraci.<\/p>\n
<\/p>\n
add_action( 'woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta' );\n\nfunction my_custom_checkout_field_update_order_meta( $order_id ) {\n if ( ! empty( $_POST['my_field_name'] ) ) {\n update_post_meta( $order_id, 'My Field', sanitize_text_field( $_POST['my_field_name'] ) );\n }\n}\n<\/pre>\n\n\n