Support » Plugin: Custom Content Shortcode » Display product categories with child

  • devpat

    (@patrykm)


    Case: I have got product categories with child, for example:

    -Category A
    |– Line Asd
    |– Line Bmn

    -Category B
    |– Line Qwe
    |– Line Rty

    How to display product child categories linked to parent separately? I mean display all combinations, so:

    – Category A | Line Asd

    – Category A | Line Bnm

    – Category B | Line Qwe

    – Category B | Line Rty

Viewing 6 replies - 1 through 6 (of 6 total)
  • polarracing

    (@polarracing)

    From the documentation:

    [for each=category parents=true]
      Parent: [each link]
      [-for each=child]
        Child: [each link]
      [/-for]
    [/for]
    Thread Starter devpat

    (@patrykm)

    Yes, I have already checked this solution. Unfortunately it shows categories and child in hierarchical order like in the admin panel. However, I want to show all the combinations, like I mentioned before:

    – Category A | Line Asd
    – Category A | Line Bnm

    NOT:
    -Category A
    |– Line Asd
    |– Line Bmn

    polarracing

    (@polarracing)

    Then use variables:

    [for each=category parents=true]
      [set var][each link][/set]
      [-for each=child]
        [get var] | [each link]
      [/-for]
    [/for]
    Thread Starter devpat

    (@patrykm)

    Thank you, it works!

    I have made some customisation:

    <div class="category-box">[for each=product_cat parents=true]
    [set var][each link][/set]
    [-for each=child]
    <div class="category-item">
    <div class="child-cat-name">[each link]</div>
    <div class="main-cat-name">[get var]</div>
    </div>
    [/-for]
    [/for]
    </div>

    Can I add also info about number of products in given product category?
    And how to link (href) whole “category-item” div to child category?

    • This reply was modified 2 months, 3 weeks ago by devpat.
    [for each=category parents=true]
      [set var][each link][/set]
      [-for each=child]
        [get var] | [each link] | [each count] | [each link]
      [/-for]
    [/for]
    Thread Starter devpat

    (@patrykm)

    Thank you – product count works great.

    But how to href my whole div.category-item?
    I try simple a href, but it doesn’t work.

    <a href="">
    <div class="category-item">
    <div class="child-cat-name">[each link]</div>
    <div class="main-cat-name">[get var]</div>
    </div>
    </a>
Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.