plugin and theme sync

This commit is contained in:
2024-03-25 02:27:05 -04:00
parent c3179e074e
commit 7d46673042
13 changed files with 358 additions and 147 deletions

View File

@@ -78,7 +78,7 @@ $carMakes = [
<div>
<label class="block mb-2 text-sm font-medium text-gray-700" for="vehicle_search_model">Model</label>
<select class="w-full px-3 py-2 border rounded-md text-gray-700 focus:outline-none focus:border-red-500" id="vehicle_search_model" name="vehicle_search_model">
<option value="" disabled="" selected="">Select Model</option>
<option value="" disabled="" selected="">All Models</option>
<!-- <option value="Camry">Camry</option>
<option value="Accord">Accord</option>
<option value="F-150">F-150</option>
@@ -101,7 +101,7 @@ $carMakes = [
<div>
<label class="block mb-2 text-sm font-medium text-gray-700" for="vehicle_search_body_type">Body Type</label>
<select class="w-full px-3 py-2 border rounded-md text-gray-700 focus:outline-none focus:border-red-500" id="vehicle_search_body_type" name="vehicle_search_body_type">
<option value="" disabled="" selected="">Select Body Type</option>
<option value="" disabled="" selected="">All Body Types</option>
<!-- <option value="Sedan">Sedan</option>
<option value="SUV">SUV</option>
<option value="Truck">Truck</option>
@@ -113,7 +113,7 @@ $carMakes = [
<div>
<label class="block mb-2 text-sm font-medium text-gray-700" for="vehicle_search_transmission">Transmission</label>
<select class="w-full px-3 py-2 border rounded-md text-gray-700 focus:outline-none focus:border-red-500" id="vehicle_search_transmission" name="vehicle_search_transmission">
<option value="" disabled="" selected="">Select Transmission</option>
<option value="" disabled="" selected="">All Transmissions</option>
<!-- <option value="Automatic">Automatic</option>
<option value="Manual">Manual</option>
<option value="CVT">CVT</option> -->
@@ -123,7 +123,7 @@ $carMakes = [
<div>
<label class="block mb-2 text-sm font-medium text-gray-700" for="vehicle_search_trim">Trim</label>
<select class="w-full px-3 py-2 border rounded-md text-gray-700 focus:outline-none focus:border-red-500" id="vehicle_search_trim" name="vehicle_search_trim">
<option value="" disabled="" selected="">Select Trim</option>
<option value="" disabled="" selected="">All Trims</option>
<!-- <option value="LE">LE</option>
<option value="EX">EX</option>
<option value="XLT">XLT</option>

View File

@@ -0,0 +1,79 @@
<?php
/*
Template Name: Appointment Page
*/
get_header();
// The Loop
if (have_posts()) {
while (have_posts()) {
the_post();
$post_meta = get_post_meta(get_the_ID(), '', true);
?>
<main id="content-container" class="overflow-scroll no-scrollbar">
<div class="max-w-7xl mx-auto">
<h2><?php the_title(); ?></h2>
<div><?php the_content(); ?></div>
<div id="appointment-body"></div>
</div>
</main>
<script>
document.addEventListener('DOMContentLoaded', function() {
let rawVehicleDetails = <?php echo json_encode($post_meta); ?>;
let postDetails = {};
for (let key in rawVehicleDetails) {
if (rawVehicleDetails.hasOwnProperty(key)) {
if (key === 'vehicle' && rawVehicleDetails[key][0]) {
postDetails[key] = JSON.parse(rawVehicleDetails[key][0]);
} else {
postDetails[key] = rawVehicleDetails[key][0] || null;
}
}
}
const appointmentForm = new AppointmentForm(postDetails.vehicle);
if(appointmentForm){
const financeForm = new FinanceForm(postDetails.vehicle, appointmentForm, ()=>{});
const appointmentBody = document.querySelector('#appointment-body');
let userForm = financeForm.initForm();
const elementsToRemove = userForm.querySelectorAll('.finance-view-only');
elementsToRemove.forEach(element => {
element.remove();
});
appointmentBody.appendChild(userForm);
const allInputs = [...appointmentForm.inputs, ...financeForm.inputs ]
allInputs.forEach(input=>{
const inputElement = userForm.querySelector(`#${input}`);
if (inputElement) {
inputElement.value = postDetails[input] || 0;
inputElement.dispatchEvent(new Event('input'));
inputElement.disabled = true;
}
})
financeForm.updateView();
}
});
</script>
<?php
}
} else {
echo 'Appointment not found.';
}
get_footer();

View File

@@ -106,9 +106,16 @@ if ($vehicle_id) {
if (!is_wp_error($similar_vehicles_response) && wp_remote_retrieve_response_code($similar_vehicles_response) === 200) {
$similar_vehicles = json_decode(wp_remote_retrieve_body($similar_vehicles_response), true);
$filtered_vehicles = array_filter($similar_vehicles, function ($vehicle) use ($vehicle_details) {
return $vehicle['id_vehicle'] !== $vehicle_details['id_vehicle'];
});
if (is_array($similar_vehicles)) {
$filtered_vehicles = array_filter($similar_vehicles, function ($vehicle) use ($vehicle_details) {
return $vehicle['id_vehicle'] !== $vehicle_details['id_vehicle'];
});
} else {
$filtered_vehicles = array_filter([], function ($vehicle) use ($vehicle_details) {
return $vehicle['id_vehicle'] !== $vehicle_details['id_vehicle'];
});
}
// echo '<pre>';
// print_r($filtered_vehicles);
@@ -480,9 +487,29 @@ $image_description = !empty($vehicle_images[0]['description']) ? $vehicle_images
<?php
get_footer();
// Extracting necessary details
$importantDetails = array(
'title' => $vehicle_details['year'] . ' ' . $vehicle_details['make'] . ' ' . $vehicle_details['model'] . ' ' . $vehicle_details['trim'] . ' - ' . $vehicle_details['exterior_color'] . ' ' . $vehicle_details['interior_color'],
'id_vehicle' => $vehicle_details['id_vehicle'],
'advertise_price'=> $vehicle_details['advertise_price']
);
// Encoding important details as JSON
$importantDetailsJSON = json_encode($importantDetails);
?>
<script>
// Assigning important details JSON to a JavaScript variable
const appointmentVehicle = <?php echo $importantDetailsJSON; ?>;
// Creating a new object to merge with appointment form data
const mergedDetails = {
image_title: <?php echo json_encode($vehicle_images[0]['url']); ?>,
...appointmentVehicle
};
// modal
const handleFinanceChanges = (financeForm) => {
if (document.querySelectorAll('.paymentSpan').length) {
@@ -515,8 +542,8 @@ get_footer();
};
const vehicleDetails = <?php echo json_encode($vehicle_details); ?>;
const appointmentForm = new AppointmentForm();
const financeForm = new FinanceForm(vehicleDetails, handleFinanceChanges);
const appointmentForm = new AppointmentForm(mergedDetails);
const financeForm = new FinanceForm(vehicleDetails, appointmentForm, handleFinanceChanges);
const modal = new Modal(<?php echo $vehicle_id ?>);
document.body.appendChild(modal.initModal());
@@ -586,7 +613,6 @@ get_footer();
var queryString = window.location.search;
var urlParams = new URLSearchParams(queryString);
var filters = JSON.parse(decodeURIComponent(urlParams.get('filters')));
console.log(filters);
setFeatureImage(0);
const accordionHeaders = document.querySelectorAll('[data-accordion-target]');
accordionHeaders.forEach(header => {