It's really great that you fixed issue #2913356, but unfortunately there is a bug in dc_ajax_add_cart_filter_commerce_line_item_by_commerce_product() that causes quite severe problems if there is no product type with the machine name "product", leading to an ajax error when you try to add any product to the cart.

The problem is that dc_ajax_add_cart_filter_commerce_line_item_by_commerce_product() compares $line_item->type to the existing machine names for product types. However, $line_item->type is not the machine name of the product type of the line item but rather a string that signifies which type of line item it is. Possible values are for example "product", "shipping" and "commerce_discount". Thus, all you need to do really is to check whether $line_item->type equals "product" because it's the same no matter the product type. A patch is coming.

Comments

ordermind created an issue. See original summary.

ordermind’s picture

Status: Active » Needs review
StatusFileSize
new1.4 KB

Here's the patch. Since dc_ajax_add_cart_filter_commerce_line_item_by_commerce_product() was only called from one place and the filter is quite simple now I got rid of that function altogether and replaced it with an array_filter() with an anonymous callback.

subhojit777’s picture

Status: Needs review » Needs work

Thank you for catching the problem and writing a fix for that. The code written earlier had problems, I don't want to repeat that. Could you please write a test for this. The test should support the changes you have made. Attach patches with and without the fix. The patch without the fix should fail.