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.
I cant get it to work.
Would u mind to take a look?
http://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?
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.
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 */
}