fixed address section of vendor-settings and user-profile
This commit is contained in:
parent
58ac2155cb
commit
4a8603ee48
|
@ -205,7 +205,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
<div class="ec-vendor-detail-block ec-vendor-block-contact space-bottom-30">
|
||||
<h6>Contact number</h6>
|
||||
<ul>
|
||||
<li><strong><?php echo $customer_data[0]['phone_number'] ?></li>
|
||||
<li><strong><?php echo $customer_data['phone_number'] ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -216,6 +216,9 @@ if ($_SESSION["isVendor"] == true) {
|
|||
<div class="shipping">
|
||||
<?php foreach ($customer_data[0]['address'] as $address) : ?>
|
||||
<?php if ($address['shipping']) : ?>
|
||||
<div>
|
||||
<span style="font-size:16px;font-weight:800;">Shipping Address:</span>
|
||||
</div>
|
||||
<div class="sName">
|
||||
<span>Name:
|
||||
<span id="selectedFName"><?php echo $address['first_name']; ?></span>
|
||||
|
@ -236,8 +239,60 @@ if ($_SESSION["isVendor"] == true) {
|
|||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($address['billing']) : ?>
|
||||
<div>
|
||||
<span style="font-size:16px;font-weight:800;">Billing Address:</span>
|
||||
</div>
|
||||
<div class="sName">
|
||||
<span>Name:
|
||||
<span id="selectedBillingFName"><?php echo $address['first_name']; ?></span>
|
||||
<span id="selectedBillingLName"> <?php echo $address['last_name']; ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="sContact">
|
||||
<span id="selectedBillingContact">Contact #: <?php echo $address['phone']; ?></span>
|
||||
</div>
|
||||
<div class="sAddress">
|
||||
<span>Address:
|
||||
<span id="sBillingBuilding"><?php echo $address['address_1']; ?></span>
|
||||
<span id="sBillingStreet"><?php echo $address['address_2']; ?></span>
|
||||
<span id="sBillingBarangay"><?php echo $address['barangay']; ?></span>
|
||||
<span id="sBillingCity"><?php echo $address['city']; ?></span>
|
||||
<span id="sBillingProvince"><?php echo $address['province']; ?></span>
|
||||
<span id="sBillingCountry"><?php echo $address['country']; ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<!-- <div class="billing">
|
||||
<php foreach ($customer_data[0]['address'] as $address) : ?>
|
||||
<php if ($address['billing']) : ?>
|
||||
<div>
|
||||
<span style="font-size:16px;font-weight:800;"><php var_dump($address); ?>Billing Address:</span>
|
||||
</div>
|
||||
<div class="sName">
|
||||
<span>Name:
|
||||
<span id="selectedBillingFName"><php echo $address['first_name']; ?></span>
|
||||
<span id="selectedBillingLName"> <php echo $address['last_name']; ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="sContact">
|
||||
<span id="selectedBillingContact">Contact #: <php echo $address['phone']; ?></span>
|
||||
</div>
|
||||
<div class="sAddress">
|
||||
<span>Address:
|
||||
<span id="sBillingBuilding"><php echo $address['address_1']; ?></span>
|
||||
<span id="sBillingStreet"><php echo $address['address_2']; ?></span>
|
||||
<span id="sBillingBarangay"><php echo $address['barangay']; ?></span>
|
||||
<span id="sBillingCity"><php echo $address['city']; ?></span>
|
||||
<span id="sBillingProvince"><php echo $address['province']; ?></span>
|
||||
<span id="sBillingCountry"><php echo $address['country']; ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<php endif; ?>
|
||||
<php endforeach; ?>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -264,16 +319,16 @@ if ($_SESSION["isVendor"] == true) {
|
|||
<div class="card-body">
|
||||
<div class="selectCon">
|
||||
<div class="selectWrap" style="display: flex; justify-content: center; align-items: center; width: 50%;">
|
||||
<!-- <input type="radio" style="padding-left: 0px !important; margin: 0px 0px !important;" name="selectedBillingAddress[<?php # echo $customer_index; ?>]" id="billing_address_<?php # echo $customer_index; ?>_<?php # echo $address_index; ?>" value="<?php # echo $customer_index; ?>_<?php # echo $address_index; ?>" class="form-check-input" onchange="updateAddressBilling('<?php # echo $customer['_id']; ?>', <?php # echo $address_index; ?>, true)" <?php # echo $address["billing"] ? 'checked' : ''; ?>> -->
|
||||
<input type="radio" style="padding-left: 0px !important; margin: 0px 0px !important;" name="selectedBillingAddress[<?php echo $customer_index; ?>]" id="billing_address_<?php echo $customer_index; ?>_<?php echo $address_index; ?>" value="<?php echo $customer_index; ?>_<?php echo $address_index; ?>" class="form-check-input" <?php echo $address["billing"] ? 'checked' : ''; ?>>
|
||||
<input type="radio" style="padding-left: 0px !important; margin: 0px 0px !important;" name="selectedBillingAddress[<?php echo $customer_index; ?>]" id="billing_address_<?php echo $customer_index; ?>_<?php echo $address_index; ?>" value="<?php echo $customer_index; ?>_<?php echo $address_index; ?>" class="form-check-input" onchange="updateAddressBilling('<?php echo $customer['_id']; ?>', <?php echo $address_index; ?>, true)" <?php echo $address["billing"] ? 'checked' : ''; ?>>
|
||||
<!-- <input type="radio" style="padding-left: 0px !important; margin: 0px 0px !important;" name="selectedBillingAddress[<?php # echo $customer_index; ?>]" id="billing_address_<?php # echo $customer_index; ?>_<?php # echo $address_index; ?>" value="<?php # echo $customer_index; ?>_<?php # echo $address_index; ?>" class="form-check-input" <?php # echo $address["billing"] ? 'checked' : ''; ?>> -->
|
||||
<label class="form-check-label" style="margin: 0px 10px !important;" for="billing_address_<?php echo $customer_index; ?>_<?php echo $address_index; ?>">
|
||||
Billing Address
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="selectWrap" style="display: flex; justify-content: center; align-items: center; width: 50%; margin-left:-20px;">
|
||||
<!-- <input type="radio" style="padding-left: 0px !important; margin: 0px 0px !important;" name="selectedShippingAddress[<?php # echo $customer_index; ?>]" id="shipping_address_<?php # echo $customer_index; ?>_<?php # echo $address_index; ?>" value="<?php # echo $customer_index; ?>_<?php # echo $address_index; ?>" class="form-check-input" onchange="updateAddressShipping('<?php # echo $customer['_id']; ?>', <?php # echo $address_index; ?>, true)" <?php # echo $address["shipping"] ? 'checked' : ''; ?>> -->
|
||||
<input type="radio" style="padding-left: 0px !important; margin: 0px 0px !important;" name="selectedShippingAddress[<?php echo $customer_index; ?>]" id="shipping_address_<?php echo $customer_index; ?>_<?php echo $address_index; ?>" value="<?php echo $customer_index; ?>_<?php echo $address_index; ?>" class="form-check-input" <?php echo $address["billing"] ? 'checked' : ''; ?>>
|
||||
<input type="radio" style="padding-left: 0px !important; margin: 0px 0px !important;" name="selectedShippingAddress[<?php echo $customer_index; ?>]" id="shipping_address_<?php echo $customer_index; ?>_<?php echo $address_index; ?>" value="<?php echo $customer_index; ?>_<?php echo $address_index; ?>" class="form-check-input" onchange="updateAddressShipping('<?php echo $customer['_id']; ?>', <?php echo $address_index; ?>, true)" <?php echo $address["shipping"] ? 'checked' : ''; ?>>
|
||||
<!-- <input type="radio" style="padding-left: 0px !important; margin: 0px 0px !important;" name="selectedShippingAddress[<?php # echo $customer_index; ?>]" id="shipping_address_<?php # echo $customer_index; ?>_<?php # echo $address_index; ?>" value="<?php # echo $customer_index; ?>_<?php # echo $address_index; ?>" class="form-check-input" <?php # echo $address["billing"] ? 'checked' : ''; ?>> -->
|
||||
<label class="form-check-label" style="margin: 0px 10px !important;" for="shipping_address_<?php echo $customer_index; ?>_<?php echo $address_index; ?>">
|
||||
Shipping Address
|
||||
</label>
|
||||
|
@ -313,7 +368,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<button type="button" onclick="updateAddressBilling('<?php echo $customer['_id']; ?>', <?php echo $address_index; ?>, true)">Use Selected Address</button>
|
||||
<!-- <button type="button" onclick="updateAddressBilling('<?php # echo $customer['_id']; ?>', <?php # echo $address_index; ?>, true)">Use Selected Address</button> -->
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1085,6 +1140,27 @@ if ($_SESSION["isVendor"] == true) {
|
|||
if (!updateResponse.ok) {
|
||||
throw new Error(`Failed to update address: ${updateResponse.status}`);
|
||||
}
|
||||
|
||||
const selectedBillingElement = document.getElementById('selectedBillingFName');
|
||||
const selectedBillingLNameElement = document.getElementById('selectedBillingLName');
|
||||
const selectedBillingContactElement = document.getElementById('selectedBillingContact');
|
||||
const sBillingBuildingElement = document.getElementById('sBillingBuilding');
|
||||
const sBillingStreetElement = document.getElementById('sBillingStreet');
|
||||
const sBillingBarangayElement = document.getElementById('sBillingBarangay');
|
||||
const sBillingCityElement = document.getElementById('sBillingCity');
|
||||
const sBillingProvinceElement = document.getElementById('sBillingProvince');
|
||||
const sBillingCountryElement = document.getElementById('sBillingCountry');
|
||||
if (selectedBillingElement) {
|
||||
selectedBillingElement.textContent = customerData.address[addressIndex].first_name;
|
||||
selectedBillingLNameElement.textContent = customerData.address[addressIndex].last_name;
|
||||
selectedBillingContactElement.textContent = 'Contact #: ' + customerData.address[addressIndex].phone;
|
||||
sBillingBuildingElement.textContent = customerData.address[addressIndex].address_1;
|
||||
sBillingStreetElement.textContent = customerData.address[addressIndex].address_2;
|
||||
sBillingBarangayElement.textContent = customerData.address[addressIndex].barangay;
|
||||
sBillingCityElement.textContent = customerData.address[addressIndex].city;
|
||||
sBillingProvinceElement.textContent = customerData.address[addressIndex].province;
|
||||
sBillingCountryElement.textContent = customerData.address[addressIndex].country;
|
||||
}
|
||||
console.log(`Address updated successfully for customer ${customerId}`);
|
||||
} catch (error) {
|
||||
console.error('Error updating address:', error.message);
|
||||
|
@ -1162,8 +1238,8 @@ if ($_SESSION["isVendor"] == true) {
|
|||
sCountryElement.textContent = customerData.address[addressIndex].country;
|
||||
}
|
||||
console.log(`Address updated successfully for customer ${customerId}`);
|
||||
location.reload();
|
||||
header("location: user-profile.php");
|
||||
// location.reload();
|
||||
// header("location: user-profile.php");
|
||||
} catch (error) {
|
||||
console.error('Error updating address:', error.message);
|
||||
}
|
||||
|
|
|
@ -265,10 +265,6 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="billing">
|
||||
<?php foreach ($vendorData['address'] as $address) : ?>
|
||||
<?php if ($address['billing']) : ?>
|
||||
<div>
|
||||
<span style="font-size:16px;font-weight:800;">Billing Address:</span>
|
||||
|
@ -295,6 +291,34 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<!-- <div class="billing">
|
||||
<php foreach ($vendorData['address'] as $address) : ?>
|
||||
<php if ($address['billing']) : ?>
|
||||
<div>
|
||||
<span style="font-size:16px;font-weight:800;">Billing Address:</span>
|
||||
</div>
|
||||
<div class="sName">
|
||||
<span>Name:
|
||||
<span id="selectedBillingFName"><php echo $address['first_name']; ?></span>
|
||||
<span id="selectedBillingLName"> <php echo $address['last_name']; ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="sContact">
|
||||
<span id="selectedBillingContact">Contact #: <php echo $address['phone']; ?></span>
|
||||
</div>
|
||||
<div class="sAddress">
|
||||
<span>Address:
|
||||
<span id="sBillingBuilding"><php echo $address['address_1']; ?></span>
|
||||
<span id="sBillingStreet"><php echo $address['address_2']; ?></span>
|
||||
<span id="sBillingBarangay"><php echo $address['barangay']; ?></span>
|
||||
<span id="sBillingCity"><php echo $address['city']; ?></span>
|
||||
<span id="sBillingProvince"><php echo $address['province']; ?></span>
|
||||
<span id="sBillingCountry"><php echo $address['country']; ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<php endif; ?>
|
||||
<php endforeach; ?>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue