diff --git a/checkouttest.php b/checkouttest.php index 1b805a6..9b8f509 100644 --- a/checkouttest.php +++ b/checkouttest.php @@ -1151,11 +1151,9 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] $freeShipping = true; } - // Set the shipping fee based on the condition $shippingFee = $freeShipping ? 0 : $checkout['shipping_fee']; - // Calculate total amount for each item - $totalAmount += ($item['price'] + $shippingFee) * $item['quantity']; + $totalAmount += ($item['price'] * $item['quantity']) + $shippingFee ; } } ?> @@ -1288,6 +1286,30 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] } } else if (pay2RadioButton.checked) { try { + const selectedFName = document.getElementById('selectedFName').innerText; + const selectedLName = document.getElementById('selectedLName').innerText; + const selectedContact = document.getElementById('selectedContact').innerText; + const sBuilding = document.getElementById('sBuilding').innerText; + const sStreet = document.getElementById('sStreet').innerText; + const sCity = document.getElementById('sCity').innerText; + const sBarangay = document.getElementById('sBarangay').innerText; + const sProvince = document.getElementById('sProvince').innerText; + const sCountry = document.getElementById('sCountry').innerText; + if ( + selectedFName.trim() === "" || + selectedLName.trim() === "" || + selectedContact.trim() === "" || + sBuilding.trim() === "" || + sStreet.trim() === "" || + sCity.trim() === "" || + sBarangay.trim() === "" || + sProvince.trim() === "" || + sCountry.trim() === "" + ) { + alert("Please select address."); + return; + } + itemNames.push(""); @@ -1335,15 +1357,15 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] method: "PATCH", body: JSON.stringify({ shipping_address: { - shipping_first_name: document.getElementById('selectedFName').innerText, - shipping_last_name: document.getElementById('selectedLName').innerText, - shipping_phone: document.getElementById('selectedContact').innerText, - shipping_address_1: document.getElementById('sBuilding').innerText, - shipping_address_2: document.getElementById('sStreet').innerText, - shipping_city: document.getElementById('sCity').innerText, - shipping_barangay: document.getElementById('sBarangay').innerText, - shipping_state: document.getElementById('sProvince').innerText, - shipping_country: document.getElementById('sCountry').innerText, + shipping_first_name: selectedFName, + shipping_last_name: selectedLName, + shipping_phone: selectedContact, + shipping_address_1: sBuilding, + shipping_address_2: sStreet, + shipping_city: sCity, + shipping_barangay: sBarangay, + shipping_state: sProvince, + shipping_country: sCountry, }, billing_address: { billing_first_name: billingFName, @@ -1367,8 +1389,6 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + token, - - // Add any additional headers as needed }, }); @@ -1376,25 +1396,14 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] throw new Error(`Error updating payment status: ${patchResponse.status} ${patchResponse.statusText}`); } }) - // Handle the result of the original POST request as needed - console.log("COD Successfull") + console.log("Payment Successfull") window.location.href = 'user-history.php'; // console.log( ); - - - // const patchResult = await patchResponse.json(); - // console.log(patchResult); - - // Handle the result of the PATCH request as needed } - - // Handle the result of the original POST request as needed - // window.open(result.attributes.checkout_url); window.location.href = result.attributes.checkout_url; } catch (error) { console.error('Error:', error); - // Handle errors } } else if (pay3RadioButton.checked) { @@ -1432,7 +1441,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] sCountry.trim() === "" ) { alert("Please select address."); - return; // Stop further execution + return; } newArray.forEach(async (orderId) => { console.log(orderId) diff --git a/forget_otp.php b/forget_otp.php index 4d8d76a..8293bc1 100644 --- a/forget_otp.php +++ b/forget_otp.php @@ -1,5 +1,5 @@ diff --git a/functions.php b/functions.php index dbfd39d..7959cd1 100644 --- a/functions.php +++ b/functions.php @@ -51,7 +51,7 @@ function sddProducts() curl_close($curl); $json = json_decode($response, true); $products = array_filter($json, function ($var) { - return ($var['promo'][0]['same-day-delivery'] === "Yes" && $var['product_type'] == '' || $var['promo'][0]['same-day-delivery'] === "Yes" && $var['product_type'] == 'simple' || $var['promo'][0]['same-day-delivery'] === "Yes" && $var['product_type'] == 'variable'); + return ($var['promo'][0]['next-day-delivery'] === "Yes" && $var['product_type'] == '' || $var['promo'][0]['next-day-delivery'] === "Yes" && $var['product_type'] == 'simple' || $var['promo'][0]['next-day-delivery'] === "Yes" && $var['product_type'] == 'variable'); }); $products = array_values($products); return $products; diff --git a/header.php b/header.php index 7bbc30b..2613191 100644 --- a/header.php +++ b/header.php @@ -897,7 +897,7 @@ if ($_SESSION["userId"] <> "") {
  • Privacy Policy
  • --> -