From 6a1d2358ecbb96189309d84b7353cccacf63d0d5 Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Tue, 26 May 2026 13:00:46 +0000 Subject: [PATCH] Fix multi-day full-day pricing: add days selector, multiply amount by rental days --- contact.php | 18 ++++++++++++------ index.html | 52 ++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/contact.php b/contact.php index 4160c95..e2c3b07 100644 --- a/contact.php +++ b/contact.php @@ -35,9 +35,13 @@ if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $date) || strtotime($date) < strtotime( echo json_encode(['success'=>false,'error'=>'Invalid or past date.']); exit; } -$pkg = PACKAGES[$package]; +$pkg = PACKAGES[$package]; +$rentalDays = ($package === 'full-day') ? max(1, min(3, (int)($input['rental_days'] ?? 1))) : 1; $rentalDate = $date; -$endDate = date('Y-m-d', strtotime($date . ' +' . $pkg['days'] . ' days')); +$endDate = ($package === 'full-day') + ? date('Y-m-d', strtotime($date . ' +' . ($rentalDays - 1) . ' days')) + : date('Y-m-d', strtotime($date . ' +' . $pkg['days'] . ' days')); +$totalAmount = ($package === 'full-day') ? $pkg['amount'] * $rentalDays : $pkg['amount']; // Check availability $conflict = db()->prepare( @@ -57,10 +61,12 @@ if ($blockedCheck->fetch()) { $ref = generateRef(); $dateLabel = date('F j, Y', strtotime($rentalDate)); -$pkgLabel = $pkg['label']; -$amountLabel = '$' . number_format($pkg['amount'], 2); +$pkgLabel = ($package === 'full-day' && $rentalDays > 1) + ? $pkg['label'] . ' × ' . $rentalDays . ' days' + : $pkg['label']; +$amountLabel = '$' . number_format($totalAmount, 2); $depositLabel = '$' . number_format(DEPOSIT_AMOUNT, 2); -$balance = $pkg['amount'] - DEPOSIT_AMOUNT; +$balance = $totalAmount - DEPOSIT_AMOUNT; $balanceLabel = '$' . number_format($balance, 2); // ── Square: create customer + card on file + deposit hold ───────────────────── @@ -143,7 +149,7 @@ $stmt = db()->prepare( VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" ); $stmt->execute([ - $ref, $name, $email, $phone, $package, $rentalDate, $endDate, $pkg['amount'], $message, + $ref, $name, $email, $phone, $package, $rentalDate, $endDate, $totalAmount, $message, $sqCustomerId, $sqCardId, $sqCardLast4, $sqCardBrand, $sqPaymentId, $sqPaymentStatus, ]); diff --git a/index.html b/index.html index df96b76..bbbac68 100644 --- a/index.html +++ b/index.html @@ -35,7 +35,7 @@ "name": "Parker County Slingshot Rentals", "description": "Polaris Slingshot rentals in Parker County, Texas. Daily and weekend rentals available for thrill-seekers near Weatherford and the DFW metroplex.", "url": "https://parkerslingshotrentals.com", - "telephone": "+1-817-555-0199", + "telephone": "+1-817-266-2022", "email": "info@parkerslingshotrentals.com", "priceRange": "$$", "currenciesAccepted": "USD", @@ -768,7 +768,7 @@
📞 - (817) 555-0199 + (817) 266-2022
✉️ @@ -808,9 +808,16 @@ + @@ -1069,14 +1076,35 @@ // ── Balance-due display ─────────────────────────────────────────────────────── const PACKAGE_PRICES = { 'half-day': 80, 'full-day': 150, 'weekend': 449 }; const DEPOSIT = 45; - const pkgSelect = document.querySelector('select[name="package"]'); + const pkgSelect = document.querySelector('select[name="package"]'); + const rentalDaysSelect = document.getElementById('rentalDaysSelect'); + const rentalDaysRow = document.getElementById('rental-days-row'); const balLabel = document.getElementById('balance-due-label'); const balAmt = document.getElementById('balance-due-amount'); + + function calcTotal(pkg, days) { + const base = PACKAGE_PRICES[pkg]; + if (!base) return null; + return pkg === 'full-day' ? base * days : base; + } + function updateBalance() { + const pkg = pkgSelect ? pkgSelect.value : ''; + const days = rentalDaysSelect ? parseInt(rentalDaysSelect.value) || 1 : 1; + const total = calcTotal(pkg, days); + if (total && balLabel && balAmt) { + balAmt.textContent = '$' + (total - DEPOSIT).toFixed(2).replace(/\.00$/, ''); + balLabel.style.display = ''; + } else if (balLabel) { + balLabel.style.display = 'none'; + } + } + if (pkgSelect) { selectedPackage = pkgSelect.value || 'half-day'; } if (pkgSelect) { pkgSelect.addEventListener('change', function() { selectedPackage = this.value; updateLegend(); + if (rentalDaysRow) rentalDaysRow.style.display = this.value === 'full-day' ? '' : 'none'; if (selectedDates.size > 0) { Promise.all([...selectedDates].map(d => hasRangeConflict(d, selectedPackage).then(c => c ? d : null))) .then(conflicts => { @@ -1087,15 +1115,12 @@ renderCalendar(calMonth, calYear); }); } else { renderCalendar(calMonth, calYear); } - const price = PACKAGE_PRICES[this.value]; - if (price && balLabel && balAmt) { - balAmt.textContent = '$' + (price - DEPOSIT).toFixed(2).replace(/\.00$/, ''); - balLabel.style.display = ''; - } else if (balLabel) { - balLabel.style.display = 'none'; - } + updateBalance(); }); } + if (rentalDaysSelect) { + rentalDaysSelect.addEventListener('change', updateBalance); + } // ── Square Web Payments ─────────────────────────────────────────────────────── let squareCard = null; @@ -1166,11 +1191,14 @@ setDepStatus('Card verified — authorizing $45 deposit hold…', 'processing'); } + const pkgVal = form.querySelector('[name="package"]').value; + const daysVal = pkgVal === 'full-day' ? (parseInt(form.querySelector('[name="rental_days"]')?.value) || 1) : 1; const data = { name: form.querySelector('[name="name"]').value, email: form.querySelector('[name="email"]').value, phone: form.querySelector('[name="phone"]').value, - package: form.querySelector('[name="package"]').value, + package: pkgVal, + rental_days: daysVal, date: form.querySelector('[name="date"]').value, message: form.querySelector('[name="message"]').value, square_token: squareToken,