Allow specific products to override the price

Using the filter cocart_is_allowed_to_override_price, you can run through a loop of product ID’s to return the statement as true for them only and return false for every other product your not checking.

This will allow you to only override the price of those products and no other.

add_filter( 'cocart_is_allowed_to_override_price', 'only_override_these_product_prices', 10, 1 );
function only_override_these_product_prices( $cart_item ) {
    if ( in_array( $cart_item, array( '24', '784', '451' ) ) ) {
        return true;
    return false;

Tip: Add the filter using a code snippet plugin for quick application.

Was this helpful to you?