{"id":6433,"date":"2021-10-29T11:56:00","date_gmt":"2021-10-29T11:56:00","guid":{"rendered":"https:\/\/musilda.cz\/?p=6433"},"modified":"2021-10-29T11:56:00","modified_gmt":"2021-10-29T11:56:00","slug":"automaticka-aktualizace-kosiku-ve-woocommerce","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/automaticka-aktualizace-kosiku-ve-woocommerce\/","title":{"rendered":"Automatick\u00e1 aktualizace ko\u0161\u00edku ve WooCommerce"},"content":{"rendered":"\n

Ve WooCommerce se ko\u0161\u00edk aktualizuje pomoc\u00ed tla\u010d\u00edtka „Aktualizovat ko\u0161\u00edk“. Tento k\u00f3d v\u00e1m pom\u016f\u017ee to zm\u011bnit a aktualizovat ko\u0161\u00edk po ka\u017ed\u00e9 akci.<\/p>\n\n\n\n

Nejprve skryjeme tla\u010d\u00edtko, aby nebylo vid\u011bt:<\/p>\n\n\n\n

.cart-table-actions .button{\n\topacity:0;\n\theight:0;\n\twidth: 0;\n\tposition: absolute;\n}<\/code><\/pre>\n\n\n\n

A n\u00e1sledn\u011b:<\/p>\n\n\n\n

add_action( 'wp_footer', 'cart_update_qty_script' );\nfunction cart_update_qty_script() {\n    if ( is_cart() ) :\n    ?>\n    <script>\n\tdocument.addEventListener('change', function(event) {\n\t\tif ( event.target.classList.contains( 'qty' ) ) {\n\t\t\tupdateCart()\n\t\t}\n\t});\n\tfunction updateCart() {\n\t\tvar updateButton = document.getElementsByName( 'update_cart' );\n\t\tupdateButton[0].disabled = false;\n\t\tupdateButton[0].dispatchEvent( new MouseEvent('click', {\n\t\t\tbubbles: true,\n\t\t\tcancelable: true,\n\t\t\tview: window,\n\t\t}) );\n\t}\n    <\/script>\n    <?php\n    endif;\n}<\/code><\/pre>\n\n\n\n

A to je v\u0161e. Dneska to bylo celkem rychl\u00e9, ale nen\u00ed t\u0159eba ps\u00e1t komplikovan\u00e9 funkce, kdy\u017e si porad\u00edme css a js. A v\u0161imn\u011bte si, \u017ee jsme se vyhnuli jQuery.<\/p>\n","protected":false},"excerpt":{"rendered":"

Ve WooCommerce se ko\u0161\u00edk aktualizuje pomoc\u00ed tla\u010d\u00edtka „Aktualizovat ko\u0161\u00edk“. Tento k\u00f3d v\u00e1m pom\u016f\u017ee to zm\u011bnit a aktualizovat ko\u0161\u00edk po ka\u017ed\u00e9 akci. Nejprve skryjeme tla\u010d\u00edtko, aby nebylo vid\u011bt: A n\u00e1sledn\u011b: A to je v\u0161e. Dneska to bylo celkem rychl\u00e9, ale nen\u00ed t\u0159eba ps\u00e1t komplikovan\u00e9 funkce, kdy\u017e si porad\u00edme css a js. A v\u0161imn\u011bte si, \u017ee jsme<\/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":[29],"tags":[],"class_list":["post-6433","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\/6433"}],"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=6433"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6433\/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=6433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=6433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=6433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}