• Resolved roadlink

    (@roadlink)


    Hi There,
    I have a custom stock status, which called EOL.
    I use it for discontinued products.

    This plugin report these products as in_stock. It should be out_of_stock
    I got several warning from google merchant to fix it.
    How Can I fix it?

Viewing 1 replies (of 1 total)
  • Thread Starter roadlink

    (@roadlink)

    This seems solution both for google and facebook plugins.

    // Check if the function from Facebook for woocommerce plugin exists
    if ( class_exists( 'WC_Facebookcommerce_Integration' ) ) {
    add_filter( 'facebook_for_woocommerce_integration_prepare_product_data', 'adjust_facebook_availability_for_eol_products', 10, 2 );
    }

    function adjust_facebook_availability_for_eol_products( $product_data, $product ) {
    if ( 'EOL' === $product->get_stock_status() || 'EOL' === $product->get_meta( '_stock_status' ) ) {
    $product_data['availability'] = 'out of stock';
    }
    return $product_data;
    }


    // Check if the function from Google for woocommerce plugin exists
    if ( function_exists( 'woocommerce_gla_product_attribute' ) ) {
    add_filter( 'woocommerce_gla_product_attribute', 'adjust_google_availability_for_eol_products', 10, 3 );
    }

    function adjust_google_availability_for_eol_products( $value, $product, $attribute ) {
    if ( 'availability' === $attribute ) {
    if ( 'EOL' === $product->get_stock_status() || 'EOL' === $product->get_meta( '_stock_status' ) ) {
    $value = 'out of stock';
    }
    }
    return $value;
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.