add product thumbnail to checkout page only and include variation name

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, … Read more

button to toggle css styling / div visibility?

The getElementsByClassName, as the name suggests returns a collection of Elements, meaning an array, so x.style.display won’t work. x[0].style.display would work for the first element that it finds. But since this is WordPress, which by default loads Jquery, you could use: jQuery(‘.cart-multi-step-button-1’).click(function(){ jQuery(‘.cart_totals’).css({ ‘background’: ‘red’, ‘display’: ‘none’, }); }); You could also toggle a class … Read more

Hide empty custom field

I’m assuming what you want is to hide the text when meta is empty. You can put a conditional check for meta before print: add_action( ‘woocommerce_single_product_summary’, ‘also_available_on_ps4’, 38 ); function also_available_on_ps4() { global $product; if ( has_term( ‘ps4-games’, ‘product_cat’ ) ) { if(get_post_meta( get_the_ID(), ‘also_available’, true )){ echo ‘<b>Also available on:</b>’ . get_post_meta( get_the_ID(), ‘also_available’, … Read more

Shortcode displaying outside the div [duplicate]

You could put all the html in a variable and return it $r = “<div id=\”” . $s[‘id’] . “\”…”; if (!empty($s[‘fb’])) { $r .= “<a href=\” . $s[‘fb’] . “…”; } $r .= “title=\”Follow Us On Facebook\” “; $r .= “target=\”_blank\” “; return $r; But every shortcode on your site should do this, for … Read more

Multiple Notifications SetInterval

There’s two approaches you may want to use here, depending on the notification behavior desired: To notify each user any time there are new notifications: You need to make sure your sql query returns the notifications in a sorted order (preferably with descending data timestamps) and includes a unique identifier/primary ID [PID] for the rows … Read more