Using field data as include file name [RESOLVED]

I am trying to use form field data to call an include file in a PDF. The field value is “COVIDTEST1”.

This code works:

<? php include ("includes/COVIDTEST1.html"); ?>

This code doesn’t work

<? php include ("includes/".$sku.".html"); ?> <? php include ("includes/{:163}.html"); ?> <? php include ("includes/{:163}.html"); ?>

Why does hardcode work while these and more variables producesnothing.

Hi Larry. I recommend logging to the console log or a debug log file to see what the $sku variable contains when you try to use it. Additionally, where are you using this code? The merge tag {:163} won’t work outside of Gravity Forms.

$sku in my test contains the value “COVIDTEST1” it’s coming over from a gravity woocommerce form

I’m using the merge tags on a PDF template.

I’ve even hardcoded $sku = “COVIDTEST1” and it fails.

My html file is a table.

I got it working

$sku = $form_data[‘field’][114];

1 Like