Title: Displaying Elements in Function
Last modified: November 26, 2020

---

# Displaying Elements in Function

 *  Resolved [coatsy35](https://wordpress.org/support/users/coatsy35/)
 * (@coatsy35)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/displaying-elements-in-function/)
 * Hi,
 * How do you correctly set the below function to display the contents of the element?
   as it stands now it just prints the elements name instead of the content?
 *     ```
       function is_element_empty($element) {
       	if(empty($element)) {
       		return "{Billing First Name} {Billing Last Name}";
       	} else {
       		return "{Billing Company}";
       	}
       }
       ```
   
 * Thanks

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [coatsy35](https://wordpress.org/support/users/coatsy35/)
 * (@coatsy35)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/displaying-elements-in-function/#post-13714331)
 * I discovered I can use the following if there is only one item in my order, however
   if there are multiple items it replaces the result with the word “Array”. How
   do I fix this?
 *     ```
       // Add VAT onto individual item cost to generate individual item gross value including VAT
       function price_inc_vat($cost, $vat) {
       	$incvat=$cost+$vat;
       	return "$incvat";
       }
       ```
   
 * I call it using: [price_inc_vat({Item Cost},{Item Tax})], do I need to put a 
   foreach in there somewhere?
    -  This reply was modified 5 years, 5 months ago by [coatsy35](https://wordpress.org/support/users/coatsy35/).
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/displaying-elements-in-function/#post-13728063)
 * Hi [@coatsy35](https://wordpress.org/support/users/coatsy35/),
 * I just posted an example snippet in your other thread that should be helpful:
   [https://wordpress.org/support/topic/number-addition/#post-13728054](https://wordpress.org/support/topic/number-addition/#post-13728054).
   Basically if there are multiple items then the cost and tax elements will be 
   an array, if there’s a single time then they’ll be strings.
 *  Thread Starter [coatsy35](https://wordpress.org/support/users/coatsy35/)
 * (@coatsy35)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/displaying-elements-in-function/#post-13728109)
 * Thanks, that response above of mine was meant to be in the other thread!
 * For this thread, how do you get it to print the elements name instead of the 
   tag? i.e. {Billing Company} in a function as per my question above?
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/displaying-elements-in-function/#post-13751980)
 * Hey [@coatsy35](https://wordpress.org/support/users/coatsy35/),
 * My apologies for the confusion. You need to pass the elements to the function
   in order for it to be able to return them. For example:
 * `[is_element_empty({Billing Company},{Billing First Name},{Billing Last Name})]`
 * Then the code would look like this (note: untested example):
 *     ```
       function is_element_empty( $company, $first, $last ) {
       	if(empty($company)) {
       		return $first . ' ' . $last;
       	} else {
       		return $company;
       	}
       }
       ```
   
    -  This reply was modified 5 years, 5 months ago by [WP All Import](https://wordpress.org/support/users/wpallimport/).
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/displaying-elements-in-function/#post-13809939)
 * Hi [@coatsy35](https://wordpress.org/support/users/coatsy35/),
 * I’m marking this as resolved since we haven’t heard back. Let us know if you 
   still have questions about this.
 * Anyone else, please open a new topic.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Displaying Elements in Function’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/displaying-elements-in-function/#post-13809939)
 * Status: resolved