{"id":5100,"date":"2018-10-29T20:54:35","date_gmt":"2018-10-29T20:54:35","guid":{"rendered":"https:\/\/musilda.cz\/?p=5100"},"modified":"2018-10-29T20:54:35","modified_gmt":"2018-10-29T20:54:35","slug":"skryti-variant-ktere-nejsou-skladem-woocommerce","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/skryti-variant-ktere-nejsou-skladem-woocommerce\/","title":{"rendered":"Skryt\u00ed variant kter\u00e9 nejsou skladem WooCommerce"},"content":{"rendered":"\n

Dnes to bude rychlovka. Na jednom eshopu se z n\u011bjak\u00e9ho d\u016fvodu p\u0159estaly skr\u00fdvat nedostupn\u00e9 varianty ve v\u00fdb\u011bru, na detailu produktu.<\/p>\n\n\n\n

Trvalo mi to docela dlouho, ale nakonec je \u0159e\u0161en\u00ed jednoduch\u00e9, i kdy\u017e trochu dvouse\u010dn\u00e9.<\/p>\n\n\n\n

Probl\u00e9mem je tento z\u00e1pis:<\/p>\n\n\n\n

$get_variations = count( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );<\/pre>\n\n\n\n

Zkr\u00e1tka, pokud je variant v\u00edce ne\u017e 30, WooCommerce se na to prost\u011b vy…. a nab\u00eddne v\u00e1m kompletn\u00ed select v\u0161ech vlastnost\u00ed. P\u0159i v\u00fdb\u011bru pak zobrazuje, zda je polo\u017eka dostupn\u00e1, \u010di ne. Sta\u010d\u00ed do functions.php p\u0159idat \u00fapravu filtru:<\/p>\n\n\n\n

add_filter( 'woocommerce_ajax_variation_threshold', 'toret_wc_inc_ajax_threshold' );\nfunction toret_wc_inc_ajax_threshold() {\n    return 300;\n}<\/pre>\n\n\n\n

a je to vybaven\u00e9. Pozor v\u0161ak na to, \u017ee to m\u016f\u017ee tro\u0161ku zpomalit na\u010d\u00edt\u00e1n\u00ed str\u00e1nky.<\/p>\n","protected":false},"excerpt":{"rendered":"

Dnes to bude rychlovka. Na jednom eshopu se z n\u011bjak\u00e9ho d\u016fvodu p\u0159estaly skr\u00fdvat nedostupn\u00e9 varianty ve v\u00fdb\u011bru, na detailu produktu. Trvalo mi to docela dlouho, ale nakonec je \u0159e\u0161en\u00ed jednoduch\u00e9, i kdy\u017e trochu dvouse\u010dn\u00e9. Probl\u00e9mem je tento z\u00e1pis: $get_variations = count( $product->get_children() ) <= apply_filters( ‚woocommerce_ajax_variation_threshold‘, 30, $product ); Zkr\u00e1tka, pokud je variant v\u00edce ne\u017e<\/p>\n","protected":false},"author":1,"featured_media":8732,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,28],"tags":[407,425],"class_list":["post-5100","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-woocommerce","category-woocommerce-reseni-problemu","tag-vyprodane-produkty","tag-woocommerce"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/5100"}],"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=5100"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/5100\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/8732"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=5100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=5100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=5100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}