• Resolved n13design

    (@n13design)


    I’m trying to display payment terms based on a number in a custom field called pay_terms. Basically 100 means paid in full while any other number will be applied to the Net Days.

    I know how to display but I can’t figure out how to use it in a conditional statement. I tried the code below but it doesn’t follow the conditional. The output of the code below looks like this: “100Payment Terms: Net Days”

    
    $payterms = $wpo_wcpdf->custom_field('pay_terms');
    if ($payterms == 100){
    echo "Payment Terms: Full payment due prior to shipment.";
    }else
    {echo "Payment Terms: Net ".$payterms." Days";
    }
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! $wpo_wcpdf->custom_field() outputs directly, it doesn’t have a return value. If you need a return value, you can use $wpo_wcpdf->getcustom_field().

    Hope that helps!

    Ewout

    Thread Starter n13design

    (@n13design)

    I tried a few things but can’t quite seem to get it to work. It breaks the template.

    <?php $payterms = $wpo_wcpdf->getcustom_field(); 
    if($payterms['pay_terms'] != 0) :?>
    <p>
    Payment Terms: <?php echo $payterms['pay_terms']; ?>
    </p>
    <?php endif; ?>
    • This reply was modified 7 years, 8 months ago by n13design.
    Plugin Contributor Ewout

    (@pomegranate)

    Hi! Apologies, I made a typo. That should have been:

    
    $wpo_wcpdf->get_custom_field()
    

    That should resolve the error.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘IF statement for custom fields’ is closed to new replies.