{"id":5663,"date":"2020-06-06T19:51:32","date_gmt":"2020-06-06T19:51:32","guid":{"rendered":"https:\/\/musilda.cz\/?p=5663"},"modified":"2020-06-06T19:51:32","modified_gmt":"2020-06-06T19:51:32","slug":"jak-ziskat-celkovou-hmotnost-objednavky-ve-woocommerce","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-ziskat-celkovou-hmotnost-objednavky-ve-woocommerce\/","title":{"rendered":"Jak z\u00edskat celkovou hmotnost objedn\u00e1vky ve WooCommerce"},"content":{"rendered":"\n

Ve WooCommerce je mo\u017en\u00e9 ka\u017ed\u00e9mu produktu p\u0159i\u0159adit hmotnost. V tomto tipu si uk\u00e1\u017eeme, jak si ulo\u017eit celkovou hmotnost produkt\u016f v ko\u0161\u00edku k vytvo\u0159en\u00e9 objedn\u00e1vce.<\/p>\n\n\n\n

Probl\u00e9m toti\u017e je, \u017ee kdy\u017e vytvo\u0159\u00edme objedn\u00e1vku, tak se hmotnost objedn\u00e1vky nikam neukl\u00e1d\u00e1. Mus\u00edme si tedy trochu pomoci. <\/p>\n\n\n\n

Snippet jsem slo\u017eil ze dvou \u010d\u00e1st\u00ed a to ulo\u017een\u00ed hmotnosti ko\u0161\u00edku k objedn\u00e1vce a potom aktualizac\u00ed v\u0161ech ji\u017e vytvo\u0159en\u00fdch objedn\u00e1vek. <\/p>\n\n\n\n

Ulo\u017een\u00ed hmotnosti objedn\u00e1vky p\u0159i jej\u00edm vytvo\u0159en\u00ed<\/h2>\n\n\n\n

Postup je jednoduch\u00fd, ko\u0161\u00edk m\u00e1 ulo\u017eenou celkovou hmotnost, kterou z\u00edsk\u00e1me get_cart_contents_weight a pomoc\u00ed akce woocommerce_checkout_update_order_meta ulo\u017e\u00edme. <\/p>\n\n\n\n

Aktualizace v\u0161ech vytvo\u0159en\u00fdch objedn\u00e1vek<\/h2>\n\n\n\n

Proto\u017ee ulo\u017een\u00ed hmotnosti u nov\u00fdch objedn\u00e1vek je n\u00e1m k ni\u010demu, pokud pot\u0159ebujeme zapsat hmotnost i u st\u00e1vaj\u00edc\u00edch objedn\u00e1vek. <\/p>\n\n\n\n

Proto si pomoc\u00ed wc_get_orders na\u010dteme v\u0161echny objend\u00e1vky ve stavu proccessin a completed, projdeme si je, zjist\u00edme u v\u0161ech produkt\u016f jejich hmotnost a tu si ulo\u017e\u00edme. <\/p>\n\n\n\n

Snippet<\/h2>\n\n\n\n\n\n\n\n

T\u00edmto snippetem jsem nav\u00e1zal na minul\u00fd, kde jsme si vytvo\u0159ili ve v\u00fdpisu administrace objedn\u00e1vek nov\u00fd sloupec, pr\u00e1v\u011b s hmotnost\u00ed – Jak p\u0159idat sloupec do administrace objedn\u00e1vek a ud\u011blat jej \u0159aditeln\u00fdm<\/a><\/p>\n\n\n\n

Dal\u0161\u00ed u\u017eite\u010dn\u00e9 snippety najdete na str\u00e1nce U\u017eite\u010dn\u00e9 snippety pro WooCommerce<\/a><\/strong> <\/p>\n","protected":false},"excerpt":{"rendered":"

Ve WooCommerce je mo\u017en\u00e9 ka\u017ed\u00e9mu produktu p\u0159i\u0159adit hmotnost. V tomto tipu si uk\u00e1\u017eeme, jak si ulo\u017eit celkovou hmotnost produkt\u016f v ko\u0161\u00edku k vytvo\u0159en\u00e9 objedn\u00e1vce. Probl\u00e9m toti\u017e je, \u017ee kdy\u017e vytvo\u0159\u00edme objedn\u00e1vku, tak se hmotnost objedn\u00e1vky nikam neukl\u00e1d\u00e1. Mus\u00edme si tedy trochu pomoci. Snippet jsem slo\u017eil ze dvou \u010d\u00e1st\u00ed a to ulo\u017een\u00ed hmotnosti ko\u0161\u00edku k objedn\u00e1vce<\/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":[19,25,29],"tags":[],"class_list":["post-5663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippety","category-woocommerce","category-woocommerce-snippety"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/5663"}],"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=5663"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/5663\/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=5663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=5663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=5663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}