This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: load order problems

#27651
skempenaarskempenaar
Participant

Hi Ernest,

Im unable to reply on your call in other topic. but on our live server it works correct Im receiving a 0.

https://www.royaljongbloed.com/wp-admin/admin-ajax.php
also on
http://rjvps.development.bladewp.com/wp-admin/admin-ajax.php

I believe I know where my problem agenda 2021 was part of. We have products that are on backorder and ajax search pro sees that as sold out.
So I like 2 use this code. But there is somehting that needs to be changed to it. Now when a product is on backorder it is put below other products
Not related to the search simple because they are instock. Could you please change it that.

If in stock and if backorder than put on top. If out of stock put to bottum.

code

// —- Ajax SEARCH PRO -put to bottom —-

add_filter(‘asp_results’, ‘asp_order_out_of_scock’, 10, 1);
function asp_order_out_of_scock($results) {
$first = array();
$last = array();
foreach ( $results as $k => &$r ) {
if ( get_post_meta($r->id, ‘_stock_status’, true) == ‘instock’ ) {
$first[] = $r;
} else {
$last[] = $r;
}
}
return array_merge($first, $last);
}