oswoptimize
Forum Replies Created
-
Forum: Plugins
In reply to: [Advanced Woo Search] AJAX search does not work properlyI realize that there shouldn’t have been a connection here. Nevertheless, this solution helped on the live site too ??
Forum: Plugins
In reply to: [Advanced Woo Search] AJAX search does not work properlyI’ve solved the problem.
I cleaned the whole site from all codes/plugins, installed the twenty-two theme, but the search bug didn’t go away. Also the usual snippet to exclude a product by ID did not work.After that I removed from search source and search table all the unnecessary data (SKU, tag, ID, short description) and everything worked.
Forum: Plugins
In reply to: [Advanced Woo Search] AJAX search does not work properlyThe updated snippet works the same as my initial snippet (ok for normal search, but doesn’t work for ajax search).
No, all the other snippets are not related to this problem (I removed them too for the test).
Forum: Plugins
In reply to: [Advanced Woo Search] AJAX search does not work properlyI can give you access to the staging site if it is convenient for you.
Forum: Plugins
In reply to: [Advanced Woo Search] AJAX search does not work properlySo did you remove your previous code snippet? – Of course
Also – do you see any errors inside your debug.log file? I added lines in config.php + reindexed the tables, but the debug.log code didn’t show up.
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );Forum: Plugins
In reply to: [Advanced Woo Search] AJAX search does not work properlyUnfortunately the result is the same. It doesn’t work for ajax search (Search result – nothing found), but it works for normal search.
Forum: Plugins
In reply to: [Advanced Woo Search] AJAX search does not work properlyYeah you are right, the problem is a conflict with the snippet. I have a product type ‘discontinued’ in my store and I used this snippet to exclude products with this status from the search results. The problem is that for normal search it works fine, but in ajax search it causes problems. Could you please tell me which snippet I can use to exclude items with discontinued status from ajax search results?
I have enabled logging and I see that the states are detected correctly (for normal search).
[08-Oct-2024 14:53:42 UTC] Product ID: 4619 has status: instock
[08-Oct-2024 14:53:42 UTC] Product ID: 1620 has status: outofstock
[08-Oct-2024 14:53:42 UTC] Product ID: 1603 has status: discontinued
[08-Oct-2024 14:53:42 UTC] Number of products after filtering: 2Problem snippet:
//Hide item with Discontinued status from aws search
add_filter( 'aws_search_results_products', 'aws_search_results_products', 10, 2 );
function aws_search_results_products( $products, $s ) {
$filtered_products = array();
foreach ( $products as $product ) {
$product_id = $product['id'];
$product_status = wc_get_product( $product_id )->get_stock_status();
if ( 'discontinued' !== $product_status ) {
$filtered_products[] = $product;
}
}
return $filtered_products;
}Settings:
Thank you,
Anton