• Resolved tictok

    (@tictok)


    Hi – I think I’m being a bit dim and struggling to get to grips with the alg_mowc_order_item_valid_as_suborder filter (line 734 of class-all-mowc-core.php)

    What can I use in my_function to get the ID of the product ($productID) being checked so that I can return true or false based on if I want that item to be split or not.

    Very simplified to show what I’m trying to do:

    
    add_filter('alg_mowc_order_item_valid_as_suborder','myfunction');
    
    myfucntion() {
    
    $split_item = false;
    
    if ($productID = 1234 ) {
    $split_item = true;
    }
    
    return $split_item;
    
    }
    

    Hope that makes sense
    Many thanks
    Stef

    • This topic was modified 4 years, 5 months ago by tictok.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tictok

    (@tictok)

    Ah, solved it. Just needed to pass the filter $args into my function:

    add_filter('alg_mowc_order_item_valid_as_suborder', 'my_selective_split_function', 10, 3);
    
    function my_selective_split_function($item_id, $main_order_item, $main_order) {
    
        $should_we_split_this_item = false;
    
        $product_id = $main_order[product_id];
        $cat_prod_id_array = get_ids_of_prods_in_my_cat();
    
        if (in_array($product_id, $cat_prod_id_array)) {
            $should_we_split_this_item = true;
        }
    
        return $should_we_split_this_item;
    }
    
    Plugin Support MeganSupport

    (@megan891)

    Hi there Stef,

    If you have any further issues please feel free to open a ticket at our website here: https://wpwham.com/support/ so that we can assist you.

    Thank you,
    WP Wham

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘check and pass product ID into alg_mowc_order_item_valid_as_suborder’ is closed to new replies.