Remove shipping method from WooCommerce cart programmatically

add_filter( ‘woocommerce_package_rates’, ‘aviweb_hide_free_shipping_class’, 10, 2 );

function aviweb_hide_free_shipping_class( $rates, $package ) {
echo $in_cart = false;
foreach( WC()->cart->cart_contents as $key => $values ) {
$product_id = $values[‘product_id’];
if ( $product_id == 2 ) {
$in_cart = true;
break;
}
}
if( $in_cart ) {
unset( $rates[‘flat_rate:7’] );
}
return $rates;
}

Advertisements

Add thumbnail description WordPress

Put below code in functions.php 

add_filter( ‘admin_post_thumbnail_html’, ‘aviweb_thumbnail_add_description’, 10, 2 );

function aviweb_thumbnail_add_description( $content, $post_id ){
$content .= “<p><b for=\”html\”>Product page (510 * 400)</b></p>”;
return $content;
return $post_id;
}