Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Bryan Purcell

    (@purcebr)

    Is this an issue you’re seeing consistently? Looks like it could be related to products that are out of stock, or a situation where the cart is referring to a product that isn’t available or retrievable.

    Thread Starter Gal Baras

    (@galbaras)

    Thanks, Bryan,

    It still happens occasionally. Looks like the validation is done at “add to cart” time, so I checked products in recent orders, but there are no errors when I add them to the cart, so this may be stopping people from successfully creating orders – definitely not good.

    To be sure, I looked up all the product pages viewed on Analytics and they can all be added to the cart with their minimum quantities and with higher quantities, including steps > 1.

    All my products were “in stock”, but I’ve now disabled inventory management completely, just in case (don’t need it anyway).

    I use both the product-specific quantity overrides and a couple of general rules. Is there a way to find out if this problem is related to one particular type or one particular product?

    Thanks,
    Gal

    Plugin Author Bryan Purcell

    (@purcebr)

    Are you on the latest version of WC?

    It looks like the code should be checking to make sure a valid product is found, and not just assuming it’s found, which is what it’s doing now. I’ll update the plugin so it won’t choke when this issue pops up. But from what I can tell, it looks like a bug in WC.

    Thread Starter Gal Baras

    (@galbaras)

    I’m on WC 2.2.8 and WCAPQ 2.1.6.

    Looking at the code, I see some inconsistencies in the way filters are declared vs. what WC uses to call them, but none that seem to matter.

    One thing that could matter is that there is no check after the call to get_product() on line 69, which could potentially return false, in which case the error above is perfectly reasonable.

    Is there a way to identify which product this is happening for? An SQL query, perhaps?

    Plugin Author Bryan Purcell

    (@purcebr)

    It seems like all this is saying is that someone tried to add a non-product, or an invalid product to the cart. What we don’t know is how that could have happened, but this validation code would fail. My question is, why doesn’t it fail earlier? I would think we shouldn’t get to this validation filter if the product id is invalid. this filter hook provides an id, and I’d say a precondition for this validation method *should be* that the product id is a valid id, which would never fail when we use get_product to retrieve. Are people complaining about the errors? maybe we could put in something to check if the result of get_product is false, and if so, error log the product_id ?

    Thread Starter Gal Baras

    (@galbaras)

    I’ve added the following code on my site (no variations for me, thankfully, but the generic code should cater for them, perhaps):

    if ( false === $product ) {
    	error_log( "Function validate_single_product called for nonexistent product_id with args: passed: $passed, product_id: $product_id, quantity: $quantity, from_cart: $from_cart" );
    }

    Let’s see what happens in the next few days.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Fatal error Call to a member function get_title() on a non-object’ is closed to new replies.