Woocommerce – Remove cart button depending product (post) status

Finally find my solution after a few day. In case someone try to do the same function test_expired_product(){ $id = get_the_ID(); $post_status = get_post_status($id); $terms= array(‘cursus-annuel’); if ($post_status === ‘expired’ || $post_status === ‘canceled’) { //echo $id; // working //echo $post_status; // working add_filter(‘woocommerce_is_purchasable’, ‘__return_false’); add_action( ‘woocommerce_single_product_summary’, ‘expired_product_message’, 20 ); return; } if( has_term( $terms, … Read more

Custom product status get filtered on all product list views

I think Below code will slove your problem.I have tested it. /** * Add ‘Unread’ post status. */ function wpdocs_custom_post_status(){ register_post_status( ‘unread’, array( ‘label’ => _x( ‘Unread’, ‘post’ ), ‘label_count’ => _n_noop( ‘Unread (%s)’, ‘Unread (%s)’), ‘public’ => true, ‘exclude_from_search’ => false, ‘show_in_admin_all_list’ => true, ‘show_in_admin_status_list’ => true )); } add_action( ‘init’, ‘wpdocs_custom_post_status’ ); function … Read more

How can I restore posts from ‘trash’ with their previous post_status? – WordPress

The reason it is a draft, and what you need to do to get what you wanted is spelt out in the source code for wp_untrash_post and in the documentation for wp_untrash_post_status: https://github.com/WordPress/WordPress/blob/bbf017e550b02f5d11e409b07e689d45c984054d/wp-includes/post.php#L3668-L3685 $new_status = ( ‘attachment’ === $post->post_type ) ? ‘inherit’ : ‘draft’; /** * Filters the status that a post gets assigned when … Read more