On those lines get_post_meta()
will return an array because by default the third argument of get_post_meta()
is false
.
If you want to return a single value you should call it like so:
get_post_meta( get_the_ID(), 'invoice_service_amount', true );
Additionally, you may want to get the post meta first and then ensure you have a value (wrapping that multiplication in a conditional statement to avoid errors). Perhaps something like:
$invoice_service_amount = get_post_meta( get_the_ID(), 'invoice_service_amount', true );
$invoice_service_quantity = get_post_meta( get_the_ID(), 'invoice_service_quantity', true );
if ( ! empty( $invoice_service_amount ) && ! empty( $invoice_service_quantity ) ) {
$line_total = absint( $invoice_service_amount ) * absint( $invoice_service_quantity );
else {
$line_total = 0;
}
Related Posts:
- Error Warning: Declaration of description_walker::start_el after PHP upgrade [duplicate]
- Displaying Logged-In User Name in WordPress Menu
- Autoloading in Child Theme
- Set media upload attachment link to none and hide it in WP v3.5
- Fatal error: Call to undefined function plugin_dir_path()
- Switching wp_get_sites to get_sites
- One button to change all settings in theme customizer?
- Add custom image sizes to media uploader
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- How to add default images into theme customizer image control?
- Is $hook a global variable in WordPress
- Successful or Error Message after running mysql code in functions.php
- How can one utilize a variable as a callback function name for add_settings_field
- Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
- Include a php file from functions.php only to homepage
- Shortcode content output but not in correct place
- How to restrict page access to logged-in users?
- Get first URL from post content
- Setting custom canonical urls
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- get post based on category chosen in drop down – The ajax method
- how to make separate field in wordpress user_data_
- Add a class to the anchor tag on HTML5 gallery
- How to output a PHP file values by shortcode?
- Set the background to a default image if there isn’t a specified “featured image”
- Calling directories to load in wordpress
- WordPress Access allowed to fewer pages till user logs in
- Use DOMDocument with ob_start breaks my HTML code
- Display a specific category of products in shop page and disable code for specific actions
- different id for same element visual composer [closed]
- Tax query in pre_get_posts not working
- trigger html cleanup for all posts
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- Validation algorithm in checkout field
- Catchable fatal error: Object of class stdClass could not be converted to string after WP 4.7
- Need help enqueueing webfonts
- Add class to group inner container
- Illegal string offset in PHP function
- How to remove ?p= from wordpress short links
- Displaying text if post was within 5 hours
- Convert the_permalink() function output into string
- Adding a tag_ID column into Categories inside the admin dashboard?
- Need php code’s output to display underneath a Divi Module
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- How to make function appear in sentence?
- How to define a variable already defined in a plugin function?
- woocommerce specific quantities for product
- My website is not showing Footer section
- get_current_site() is undefined
- Custom query vars filters problem with pagination
- Automatically Add Page Links to Nav Menu
- blank white page when post/update/change option etc
- Use SCSSPHP to compile Theme Customizer Values into .SCSS files ready to compile to CSS
- Must filter functions receive all arguments passed to them?
- How to Display a List of Child Pages For a Parent Page in WordPress
- writing an unique php function to be used on my website
- Displaying Slider in Front Page (home) using Customizr Theme
- How to add PHP pagination to wordpress
- Is there a way to create a “copy post” link?
- Taxonomy term description with style, only if the description exists?
- Restrict post to current user in postmeta
- How to change the author box selection on a post to a custom taxonomy
- Output product category link from WP_Query
- Adding onload to body for certain pages
- How to send a php var to jQuery Ajax call with two different file
- copy fields value to another field
- not outputting medium size image URL
- posts_per_page displays only 2 posts instead of 4 posts
- Get parent category name when only child category is applied to a product
- Best way to use variables in multiple functions?
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- Adding product permalink on admin order page throwing error
- Before & After Content – After Content directly below Before Content when using require_once
- Cannot fetch posts with certain ‘product_cat’. WP_Query is empty
- Detect what link user clicks and Redirect to a specific page for logged in users only
- Offset with ajax load more posts duplicates
- How to call WordPress PHP file using external js file
- How fix error in the WordPress loop?
- use system script advertising in wordpress multisite
- Use WP_Query Data In Cookie
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- Insert wordpress tags below posts via functions.php
- Help with my first Metabox helper class
- ISOTOPE – Missing/Invalid Arguement Get Terms
- Showing all post from all post type in admin backstage
- Pagination not displaying
- Load a Header in wordpress
- Trouble figuring out how to get my button to submit comment
- Setting WooCommerce currency programmatically
- Masking external links with internal link for member-only
- Shortcode to include PHP file, pass various parameters to include?
- Why can’t I include echo inside a variable? [closed]
- Alternative to php echo within code
- Add multiple HTML attributes to an Elementor button
- Automatically change insurance quantity based on cart total [closed]
- How to sort custom sortable column by custom table value
- /page/2/ redirect to 404
- How to pass value to add_filter wpcf7_form_tag from another function?
- hiddenQuestions.find is not a function