• Resolved sorro445

    (@sorro445)


    Hi,
    I was wondering if there is any way to use an accordion in a woocommerce php template(inside a table).

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author philbuchanan

    (@philbuchanan)

    Yes! Just put your entire accordion content as a param of the do_shortcode() function:

    e.g.:

    $accordion = '[accordion]
    [accordion-item title="Title of accordion item"]Drop-down content goes here.[/accordion-item]
    [accordion-item title="Second accordion item"]Drop-down content goes here.[/accordion-item]
    [/accordion]';
    
    echo do_shortcode($accordion); ?>
    • This reply was modified 5 years, 6 months ago by philbuchanan.
    Thread Starter sorro445

    (@sorro445)

    Hi,
    thanks. I would need to have the content of the accordion be PHP though as well…is this possible?

    Plugin Author philbuchanan

    (@philbuchanan)

    Yes. You just need to create the string using PHP:

    <?php 
    
    $accordion = '[accordion]';
    $accordion .= '[accordion-item title="' . $your_title_here . '"]';
    $accordion .= ''; // Your PHP code for the content of the first item goes here
    $accordion .= '[/accordion-item]';
    $accordion .= '[/accordion]';
    
    echo do_shortcode($accordion); 
    
    ?>
    Thread Starter sorro445

    (@sorro445)

    Hi,
    thank you so much for helping. Unfortunately I can’t get it to work, even the first code without PHP does not display a useable accordion – headline and content are displayed at the sae time, and you cannot close or open it. Maybe Woocommerce does not allow it?

    The thing I a trying to achieve is to have the accordion title “description” underneath each product in the checkout order table, and when you click on it the accordion should open and the product description and image should be displayed(by default, Woocommerce does not display anything besides the product name in the checkout table).

    My knowledge in PHP is limited but I am really desperate in getting this to work…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using accordions in php template’ is closed to new replies.