Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'woocommerce_before_cart', 'mx_notice_for_category_in_cart' );
- function mx_notice_for_category_in_cart() {
- $category_in_cart = false;
- foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
- // Upiši "slug" kategorije za koju želiš prikaz obavijesti
- if ( has_term( 'posebna-kategorija', 'product_cat', $cart_item['product_id'] ) ) {
- $category_in_cart = true;
- break;
- }
- }
- if ( $category_in_cart ) {
- wc_print_notice( 'Proizvod u posebnoj kategoriji je u košarici', 'notice' );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement