Hi,
I have some more questions relating to this thread that Waqar previously helped me with. I followed your instructions using the existing layout but adding in the search to the view. What I found was that the drop downs on the form weren't pulling in the info so there was nothing to choose from. I've realised that in the example you made for me you selected the post type 'vehicles'. Where as in the original view 'products' are selected. If I change your view from vehicles to products it also doesn't work. I think the vehicle post type on the site is pulling in product info related to the products via a database and the plugin 'AX Sync'.
What I'm wondering is whether the script that you found that was being used to open the search form on another page is also the key to pulling in the info from the database? I don't write Javascript - I read through it and couldn't see any suggestion but as I don't know Javascript I'm not sure.
Right now my main concern is handing over the website to the client that at least works even if it's using that script (I have stressed to them that this is not a future proof option. I'm not being paid anything by them for all the extra troubleshooting work I am doing so I am keen to just hand over something that works although I will continue to try and convince them not to use it).
If this is something I could solve with toolset that would be great but I really don't know if it is or not or why the script isn't working on the other site. My next step is to downgrade wordpress to the same version as I am using 6 on the new site and I guess PHP too. Before I do that it would be good to get you opinion in case there is an easy fix that I have missed.
Hello,
I assume we are talking about the your previous thread:
https://toolset.com/forums/topic/search-on-separate-pages/
I don't see any custom scripts in it.
Please provide a test site with the same problem, provide detail steps for the question:
the drop downs on the form weren't pulling in the info so there was nothing to choose from
What options do you want to see int the drop downs?
Private message box enabled.
If you look through Waqar's responses - in the one on June 21, 2022 at 2:15 pm he provides a screenshot of the script
Alice
Hi Alice,
I'll be following up on this ticket since I have also assisted you with the previous ticket.
Can you please share the temporary admin login details of the website again, along with the link to the exact page that you'd like to be fixed?
This will help in refreshing where we left and I'll be in a better position to suggest the next steps, accordingly.
Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.
regards,
Waqar
Thank you for sharing these details, but, I'm getting the incorrect password message.
Can you please check the username and the password again?
(I've set your next reply as private)
The admin access details worked.
If your goal at the moment is only to hand over the project, with a different page builder, you'll have to make sure that:
1. All converted pages are using the exact same view's shortcodes as the original/old website.
For example, the page "eStore" page ( hidden link ) had the shortcode for the view:
[wpv-form-view name="show-vehicles-test" target_id="18276"]
But on the other website, the same page ( hidden link ) is using a different view's shortcode:
[wpv-view name="search-by-vehicle"]
I've changed the same shortcode on the new website's page ( hidden link ) and the search fields seem to be working to show the field values through the custom script.
2. On the search form's submission though, you'll see an error. That is because there are certain custom functions added in the "functions.php" file of the active "AutoXpress" theme on the original/old website ( hidden link ), which are missing from the theme "Bricks Child Theme" that is active on the new website ( hidden link ).
Those custom functions are needed for the custom scripts used by the views and you should copy all the custom code from the "functions.php" file in the old website's "AutoXpress" theme to the "functions.php" file, in the new website's "Bricks Child Theme".
( you can ignore any custom code related to the "Astra" theme though )
Thank you Waqar, it's all becoming a bit more clear now! You are right I had a different shortcode in place as I was attempting to re build the way you showed me last time.
As I am using Oxygen (I had previously considered using bricks and that is why the child theme still shows) which disables the functions php file I added the php via a plugin which is the suggested route. This is the code I added;
// This function is called by the vehicle search page to pass the vehicle code to the API and display results by sku
add_action('wp_ajax_nopriv_get_vehicles_by_skus','get_vehicles_by_skus');
add_action('wp_ajax_get_vehicles_by_skus','get_vehicles_by_skus');
function get_vehicles_by_skus() {
$vehicle_id=$_POST['id'];
$vehicle_details=$_POST['details'];
$body = '{"vehicleID": "' . $vehicle_id .'"}';
//Pass the vehicle ID to the API...and get back an array of SKUs
$api_url_root = 'hidden link';
$api_url = $api_url_root . 'api/Vehicle/allVehicleProductIDs';
$api_response = wp_remote_post( $api_url, array(
'body' => $body,
'headers' => array(
'Content-Type' => 'application/json',
),
) );
$skus = json_decode(wp_remote_retrieve_body( $api_response ), true);
foreach ($skus as $item){
$results = $results . 'sku[]='.$item.'&';
}
$results = $results . 'details[]='.$vehicle_details;
echo $results;
exit();
}
Unfortunately it is still not working and I am getting a page saying 'security check'. I've attached a screen shot of the plugin - I believe it's correct, I've never made a plug in before so I may have got something wrong..
Whenever a view is not working on the new website, as it is on the old website, you should compare their settings by opening them side-by-side.
For example, the view "Search By Vehicle" on the old website has the option "AJAX results update when visitors click on the search button" selected in the "Custom Search Settings".
But the one on the new website had the "Full page refresh when visitors click on the search button" option selected which I have changed to match the old one.
Now, when you'll select one value in the search form, others will also update accordingly.
( hidden link )
The page is not redirecting to the new page ( /show-vehicle-results/ ), because some of the links on the new website are using 'https' and others are using 'http'.
Your website is set to force SSL (https) but in the "WordPress Address (URL)" and "Site Address (URL)" fields at WP Admin -> Settings -> General, it is set to use 'http'.
I'll recommend updating those fields to use 'https' and then also changing all the URLs in the content, scripts, and styles of the view 'Search By Vehicle' to also use the 'https' for consistency.
Thank you Waqar, sorry I missed that! It's actually working!
Thanks for the update and glad that it's working now.
You're welcome to mark this ticket as resolved and start a new one, for each new question or concern.