Send optional value to paypal only if set
I am trying to use an if statement to send the on0 optional value to paypal only if a variable has a value. It's best explained with this example. If a product has no optional value, confirm.php looks like this:
<input type="hidden" name="on0_<?php echo $pkCart_Index+1; ?>" id="on0_<?php echo $pkCart_Index+1; ?>" value="" />
<input type="hidden" name="os0_<?php echo $pkCart_Index+1; ?>" id="os0_<?php echo $pkCart_Index+1; ?>" value="" />
If it does have a product with an optional value, the same section of code looks like this:
<input type="hidden" name="on0_<?php echo $pkCart_Index+1; ?>" id="on0_<?php echo $pkCart_Index+1; ?>" value="Size" />
<input type="hidden" name="os0_<?php echo $pkCart_Index+1; ?>" id="os0_<?php echo $pkCart_Index+1; ?>" value="<?php echo $pkCart->DisplayInfo("Size"); ?>" />
How do I write this correctly with an if statement?
I tried the following, but I am doing something wrong because isset always finds this false.
<input type="hidden" name="on0_<?php echo $pkCart_Index+1; ?>" id="on0_<?php echo $pkCart_Index+1; ?>" value="<?php if (isset($pkCart->size)) {?>Size<?php }?>"/>
<input type="hidden" name="os0_<?php echo $pkCart_Index+1; ?>" id="os0_<?php echo $pkCart_Index+1; ?>" value="<?php if (isset($pkCart->size)) {echo $pkCart->DisplayInfo("Size"); }?>"/>