• Hi,

    please check the file class-wc-product-compatibility.php line 47:

    return $product->is_type( 'variation' ) ? $product->variation_id : $product->id;

    Must be changed to:

    return $product->is_type( 'variation' ) ? $product->variation_id : $product->get_id();

    You can also simplify the whole function a bit:

    public static function get_id( \WC_Product $product ) {
    	if ( method_exists( $product, 'get_id' ) ) {
    		return $product->get_id();
    	}
    	return $product->is_type( 'variation' ) ? $product->variation_id : $product->get_id();
    }

    You need to test it but it should be fine.
    Thanks for you support!

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! Thanks for the report.
    Can you tell me how to reproduce an error that this triggers (step by step)? This is a compatibility class that ensures that the plugin can work with WooCommerce 2.X, which doesn’t have the get_id() method (so would crash on your solution). For WC 3.X the method_exists( $product, 'get_id' ) would always be true so it would never get to the second part.

    Let me know if I missed something but I cannot reproduce this issue here.

Viewing 1 replies (of 1 total)
  • The topic ‘Bug: Member has protected access’ is closed to new replies.