• famarast

    (@famarast)


    Hello, is there a way to exclude all orders that contain products from one or more specific categories?
    I would like the entire order not to appear in the export.

    Is there also a way to do the opposite, i.e. only include orders that have products of those specific categories?
    (I would like to exclude those orders from the normal export and do a separate export just for them)

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author algol.plus

    (@algolplus)

    hello

    Please, open section “Filter By Products” and select “product_cat” in the dropdown “Product taxonomies” .

    Use “=” or “<>”

    thanks, Alex

    Thread Starter famarast

    (@famarast)

    It doesn’t work though, I have an order which contains various products from the excluded category, I enclose a screen, but these are included in both the preview and the generated csv.
    I have tried both with the “Export all products from the order box” ticked and without the tick.

    • This reply was modified 12 months ago by famarast.
    Thread Starter famarast

    (@famarast)

    It seems to remove only the products I have excluded but I want the entire order to be removed from the export

    Plugin Author algol.plus

    (@algolplus)

    Please, open section “Misc Settings” and add this php code.
    You must edit list of excluded categories in code!
    ?
    add_filter( 'woe_order_export_started', function ( $order_id ) {
    $order = new WC_Order($order_id);
    $skip_categories = array( "74","64","84","68","87","86","77","71","82","72");
    foreach ( $order->get_items('line_item') as $item_id=>$item ) {
    $terms = get_the_terms( $item['product_id'], 'product_cat' );
    foreach ( $terms as $term ) {
    if( in_array($term->term_id,$skip_categories) )
    return false;
    }
    }
    return $order_id;
    });

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude all orders containing at least one product in a category’ is closed to new replies.