You can use the conditional checks to simply build a new return value for the filter. So run the filter once and put all your code in there.
Your second example doesn’t really make sense because no matter what, you’re returning $name, can you explain that more?
add_filter( 'woocommerce_cart_item_name', 'cart_variation_description', 20, 3);
function wpse306625_cart_variation_description( $name, $cart_item, $cart_item_key ) {
$output="";
if ( is_checkout() ) {
$item_data = $cart_item_key['data'];
$post = get_post($item_data->id);
$thumb = get_the_post_thumbnail($item_data->id, array( 32, 50));
$output="<div id="jwf_checkout_thumbnail" style="float: left; padding-right: 8px">" . $thumb . '</div>' ;
}
else {
$output .= $name;
}
return $output;
}
Related Posts:
- Hide some items from Screen options in dashboard for products
- Exclude Empty Child Categories in Menu
- Add to cart php not working [closed]
- woocommerce change currency per category [closed]
- (Woocommerce) Order by price when entering specific category
- Which method is more correct for removing WooCommerce Extensions menu item?
- Issues with title-tag and document_title_parts
- How to create a custom order status in woocommerce!
- How to show product SKU on product page
- How to influence the information displayed on widget inside wp-admin
- Woocommerce add to simple product attribute programmatically [closed]
- How to reduce original image quality on upload?
- In WooCommerce I need to modify the thankyou.php page [closed]
- Add body class of category parent
- Convert hyphen to underscore in permalinks
- Programmatically Add Font-Awesome Icons to Category Widget
- Remove bulk actions based on user role or capabilities
- How to override filter in child theme?
- Remove product description from product archive page
- How to change a certain text or term of WordPress into a custom into the whole site?
- display 100 products per page on product category page [closed]
- Adding body class when post contains a specific shortcode
- Adding WooCommerce to a Custom Theme – not working [closed]
- Can you use admin pages functionality on the frontend of your site
- Manipulate Output of wp_list_something: select menu instead of li’s
- Display WooCommerce subscriptions for user [closed]
- Increment price for Woocommerce Minicart [closed]
- Change woocommerce products weight varation based its product category or tags? [closed]
- Show excerpt for only first post in query
- Woocommerce checkout field maxlength, make input number field only (postcode)
- Get current page_id before loop, in functions.php
- Set quantity of woocommerce product on page visit [closed]
- str_replace function in theme
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- How do I add Bootstrap and LESS to my migrated WordPress site?
- How to add nav menu items to a specific position within a menu
- Passing values from a widget to a function within a plugin
- Publish/Update post is changing image links from file url to post url
- How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]
- How to display custom option field in woocommerce orders in admin panel?
- How to add a slide toggle to the Woocommerce-Layout__Activity-Panel area in the orders admin page
- Adding an external HTML link to a post thumbnail
- Replace a menu with widget or a custom template file programmatically
- Run wp_kses_decode_entities on atom feed?
- Can’t filter wp_get_attachment_link
- Override the WordPress core function wp_referer_field
- Modify post filter to set custom number of posts per page and exclude child posts
- Setting a default text for excerpts of a particular category
- How can I use Woocommerce $product->get_attribute in functions.php? (if at all)
- How to edit the Tags within the image file URLs?
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- How to add_filter html template to middle of content
- Possible to hook into Media Library preview File column and use a custom image?
- Hide thumbnail on search results when thumbnail not set – using Oxygen
- Combine embed_oembed_html and oembed_result
- How to display the_archive_title() and the_archive_description() – “weird” interaction
- add referrer to woo
- Native gallery custom html output
- The_content and Preg_replace in loaded Iframe [closed]
- Create a Woocommerce product widget with category filter
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- Adding product to WooCommerce cart [closed]
- WooCommerce -> wc_enqueue_js not working [closed]
- Use existing image sizes for WooCommerce
- Any adverse effects of adding apply_filters to a function?
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Customizing the wp_video_shortcode output with add_filter
- Change class woocommerce on function.php
- Hide ‘add to cart’ when certain value in dropdown is selected
- Removing comment lines from all enqueued js files using a filter function
- How Do I Unhook This Parent Theme Function?
- Woocommerce product price change
- Help with with my function for wordpress
- Allow user only create specific tags
- Remove clickable Link of WordPress Site Logo from Woocommerce Single Product page
- Child theme remove parent filter in functions
- Variable function names
- Woocommerce – Switching Price for Category
- Echo a String Based On Geolocation? [Woocommerce || ACF]
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- Move product attributes after summary on single product page
- Hide disclaimer from summary excerpts
- Only seems to be displaying one child when there are supposed to be multiple
- Best way to add image to recent posts widget?
- Shortcode to eliminate and replace with
- previous_post_link inside of a function?
- Search and Replace Script Loader in Head Only Works in Footer
- Problem in outputting shortcode
- Move captions under gallery images in twenty fourteen theme
- How to Add A Rel Filter to All Links?
- Allow tags and attributes in post and pages content
- Override parent theme function that is not hooked or in the functions.php file
- child_of not working while searching
- Function to get thumbnail img source
- How to Insert A List of Posts in A Category Written by the Author into the Author Archive
- Filter to strip unnecessary attributes
- Get term count on a category page
- add variable to actions/functions across different files (woocommerce)
- function to show youtube videos within excerpt – if condition and apply_filters
- Is it possible to set the first image from a gallery as the product image, rather than the featured image?