• Resolved mariodts

    (@mariodts)


    Hi we build an xml and we want to get only products that have an ean number.

    we work on this filter.

    add_filter('xml_product_visibility_control','hide_product_wpml',11,2);
    function hide_product_wpml($default,$product) {
       $meta_query[] = array(
           'key' => '_sku',
           'value' => '',
           'compare' => '!=',
           'stock_status' =>'onbackorder',
       );
       return $meta_query;
    }
    

    Now with this function, we hide products that are on backorder from our xml.
    How could we modify it to hide products without an EAN number?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Algoritmika

    (@algoritmika)

    Hi @mariodts,

    By default, our meta key is _alg_ean, so I believe it should be something like this:

    array(
        'key'     => '_alg_ean',
        'value'   => '',
        'compare' => '=',
    )

    Please give it a try and let me know what you think.

    Thread Starter mariodts

    (@mariodts)

    Thanks for the reply.
    This hook doesn’t seem to work.

    We tried this

    if ($product->get_stock_status()=="onbackorder") return false;

    and seems to hide products on backorders from xml.

    How could do the same with _alg_ean to hide products if the ean is empty?

    Thanks for all

    Plugin Author Algoritmika

    (@algoritmika)

    Hi @mariodts,

    Sure:

    if ( '' === get_post_meta( $product->get_id(), '_alg_ean', true ) ) {
        return false;
    }

    Alternatively you can use our function:

    if ( '' === alg_wc_ean()->core->get_ean( $product->get_id() ) ) {
        return false;
    }

    I hope this helps. Please let me know what you think.

    Thread Starter mariodts

    (@mariodts)

    Thanks for the reply. Worked perfect

    Plugin Author Algoritmika

    (@algoritmika)

    Hi @mariodts,

    Happy to hear it’s solved 🙂 Please let me know if you’ll need anything else.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Hide products without EAN from xml’ is closed to new replies.