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

Reply To: Hide out of stock (only in resultbox)

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Hide out of stock (only in resultbox) Reply To: Hide out of stock (only in resultbox)

#25804
skempenaarskempenaar
Participant

Hi Ernst,

found a solution. we add a tag (name of the author) of the book author if the product is in stock. our books are being imported overnight so with the following code our in stock products get reordered in ajax search pro. simply because the tag is present.

function set_author_to_tag($ProductAvailability, $value) {
if($ProductAvailability == ’21’ )
print_r($value);
if($ProductAvailability == ’22’ )
print_r($value);
if($ProductAvailability == ’23’ )
print_r($value);
if($ProductAvailability == ’10’ )
print_r($value);
if($ProductAvailability == ’30’ )
print_r($value);
if($ProductAvailability == ’32’ )
print_r($value);
}
function author_select($ProductAvailability, $type, $data){
$roles = [‘auteur’ => ‘A01′,’illustrator’ => ‘A12′,’vertaler’ => ‘B06′,’redacteur’ => ‘B01’,];
$currentRole = $roles[$type];
$contributors = [];

foreach ($data as $key => $contributor) {
$role = $contributor[0];
$first_name = $contributor[1];
$prefix = $contributor[2];
$last_name = $contributor[3];

if ($role === $currentRole) {
$prefix = ($prefix) ? $prefix . ‘ ‘ : ”;

// We have a winner
$contributors[$first_name . ‘ ‘ . $prefix . $last_name . ‘; ‘] = $key;
}
}
$value = implode(array_flip($contributors));
set_author_to_tag($ProductAvailability, $value);
}