Title: IF statement for custom fields
Last modified: March 7, 2017

---

# IF statement for custom fields

 *  Resolved [n13design](https://wordpress.org/support/users/n13design/)
 * (@n13design)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/if-statement-for-custom-fields/)
 * 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](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/if-statement-for-custom-fields/#post-8888807)
 * 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](https://wordpress.org/support/users/n13design/)
 * (@n13design)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/if-statement-for-custom-fields/#post-8894729)
 * 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 9 years, 3 months ago by [n13design](https://wordpress.org/support/users/n13design/).
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/if-statement-for-custom-fields/#post-8908702)
 * 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.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 3 replies
 * 2 participants
 * Last reply from: [Ewout](https://wordpress.org/support/users/pomegranate/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/if-statement-for-custom-fields/#post-8908702)
 * Status: resolved