{"id":6280,"date":"2021-10-04T17:42:39","date_gmt":"2021-10-04T17:42:39","guid":{"rendered":"https:\/\/musilda.cz\/?p=6280"},"modified":"2021-10-04T17:42:39","modified_gmt":"2021-10-04T17:42:39","slug":"jak-skryt-urcitou-dopravni-metodu-na-zaklade-uzivatelske-role","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-skryt-urcitou-dopravni-metodu-na-zaklade-uzivatelske-role\/","title":{"rendered":"Jak skr\u00fdt ur\u010ditou dopravn\u00ed metodu na z\u00e1klad\u011b u\u017eivatelsk\u00e9 role"},"content":{"rendered":"\n

Pro B2B e-shopy se m\u016f\u017ee hodit, skr\u00fdt ur\u010ditou dopravn\u00ed metodu, podle toho, jakou m\u00e1 u\u017eivatel roli. Nap\u0159\u00edklad pro partnery nebudete cht\u00edt povolit local pickup.<\/p>\n\n\n\n

O tom je dne\u0161n\u00ed snippet. Funguje jen pro p\u0159ihl\u00e1\u0161en\u00e9 a odstran\u00ed z pokladny definovanou dopravn\u00ed metodu:<\/p>\n\n\n\n

add_filter( 'woocommerce_package_rates', 'hide_shipping_for_user_role', 10, 2 );\n\nfunction hide_shipping_for_user_role( $rates, $package ) {\n\n    $excluded_role = 'partner';\n    $shipping_id = 'local_pickup:2';\n\n    $user = wp_get_current_user();\n    if ( empty( $user ) ) return $rates;\n\n    if( in_array( $excluded_role, (array) $user->roles ) && isset( $rates[ $shipping_id ] ) )\n        unset( $rates[ $shipping_id ] );\n\n    return $rates;\n\n}<\/code><\/pre>\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":"

Pro B2B e-shopy se m\u016f\u017ee hodit, skr\u00fdt ur\u010ditou dopravn\u00ed metodu, podle toho, jakou m\u00e1 u\u017eivatel roli. Nap\u0159\u00edklad pro partnery nebudete cht\u00edt povolit local pickup. O tom je dne\u0161n\u00ed snippet. Funguje jen pro p\u0159ihl\u00e1\u0161en\u00e9 a odstran\u00ed z pokladny definovanou dopravn\u00ed metodu: Dal\u0161\u00ed u\u017eite\u010dn\u00e9 snippety najdete na str\u00e1nce U\u017eite\u010dn\u00e9 snippety pro WooCommerce<\/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-6280","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\/6280"}],"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=6280"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6280\/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=6280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=6280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=6280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}