• Hi,

    Love the plugin1.

    I’m using the plugin to create a menu in pdf.
    I wanna create my own template.
    But when multiple checkboxes has been marked and its generating the pdf, all the data is on one line seperated by a comma.

    How can I change this into multiline?

    So instead of my data is like: One, Two, Three
    It should be:
    One
    Two
    Three

    It’s not an option to just pick every merge tag in the checkbox field and print the pdf.

    https://www.ads-software.com/plugins/gravity-forms-pdf-extended/

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

    (@blue-liquid-designs)

    I’m glad to hear you find the software useful.

    To achieve what you want you’ll need to use the $form_data array instead. It’s a pretty easy change:

    <?php
    echo implode( '<br>', $form_data['field'][20] ); //change 20 to your checkbox field ID
    ?>

    More info about the $form_data array can be found in our documentation.

    Thread Starter roundsquaredk

    (@roundsquaredk)

    I cant get it to work.
    Would u mind to take a look?
    https://madhytten.dk/?gf_pdf=1&fid=1&lid=23&template=buffet-template.php&data=1 ;

    [products] => Array
            (
                [33] => Array
                    (
                        [name] => Mad til festen
                        [price] => 0,00 kr.
                        [price_unformatted] => 0.00
                        [options] => Array
                            (
                                [0] => Array
                                    (
                                        [field_label] => Antal k?d
                                        [option_name] => 2 slags k?d (175 kr)
                                        [option_label] => Antal k?d: 2 slags k?d (175 kr)
                                        [price] => 175
                                        [price_formatted] => 175,00 kr.
                                    )
    
                                [1] => Array
                                    (
                                        [field_label] => V?lg k?d (2 slags)
                                        [option_name] => Oksem?rbrad med stegte svampe, bagte hvidl?g og timian
                                        [option_label] => V?lg k?d (2 slags): Oksem?rbrad med stegte svampe, bagte hvidl?g og timian
                                        [price] => 20
                                        [price_formatted] => 20,00 kr.
                                    )

    Here i want to get the data from all the “option_name”.
    How to do that?

    Thread Starter roundsquaredk

    (@roundsquaredk)

    I figured out to use:
    $form_data['products'][33]['options'][13][option_name]
    To get the a product. But again its on one line.

    But when i use your code:
    echo implode( '<br>', $form_data['products'][33]['options'][13][option_name] );

    It doesn’t show anything?

    Then i tried the loop

    <?php
    /* loop through all products */
    foreach($form_data['products'] as $product) {
    ?>
        <?php echo $product['name']; ?>
        <?php echo $product['price']; ?>
        <?php echo $product['quantity']; ?>
        <?php echo $product['subtotal_formatted']; ?>
        <br>
    <?php
        /* Inner loop to loop through options field */
        foreach($product['options'] as $option) {
        ?>
            <?php echo $option['field_label']; ?>
            <?php echo $option['option_name']; ?>
            <?php echo $option['option_label']; ?>
            <?php echo $option['price_formatted']; ?>
            <br>
        <?php } /* close option loop */ ?>
    ?>
    <?php } /* close foreach loop */ ?>

    But here I can’t exclude some of the option names.

    Plugin Author Jake Jackson

    (@blue-liquid-designs)

    You’ll want to use the loop for accessing the product options. You can exclude specific options by doing the following:

    foreach($product['options'] as $option) {
      $exclude = array( 'Item 1', 'Item 2', Item 3' ); /* change this to what you want excluded */
    
      if( in_array( $option['option_name'], $exclude ) ) {
          continue; /* skip over option */
      }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Multilines’ is closed to new replies.