_workContext.CurrentCustomer.Addresses where to find?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 anno tempo fa
dears
i am upgrading plugin from 4 to 4.60.1
so i want to ask about some code
first where i can find
_workContext.CurrentCustomer.Addresses
and how to add new address in it.
second where i can find  
_workContext.CurrentCustomer.BillingAddress and  _workContext.CurrentCustomer.ShippingAddress
and how to add new address in each?
1 anno tempo fa
When I do upgrades like this, I search for related code in the core, and compare / see changes that were made.  Example, compare :
   Presentation\Nop.Web\Controllers\CheckoutController.cs

From 4.20
public virtual IActionResult SelectBillingAddress(int addressId, bool shipToSameAddress = false)
...
    var address = _workContext.CurrentCustomer.Addresses.FirstOrDefault(a => a.Id == addressId);
...
    _workContext.CurrentCustomer.BillingAddress = address;


to 4.60
public virtual async Task<IActionResult> SelectBillingAddress(int addressId, bool shipToSameAddress = false)
...
    var customer = await _workContext.GetCurrentCustomerAsync();
    var address = await _customerService.GetCustomerAddressAsync(customer.Id, addressId);
1 anno tempo fa
dear New York
thanks for your support i saw this code but its for get how to set?
as i am upgrading plugin from v4 to v 4.6 there is code need to be upgraded too
as
_workContext.CurrentCustomer.BillingAddress = address;
what is the equivalent for it in 4.6 as billing address not exist in customer entity
1 anno tempo fa
You can see where it is stored just after the above lines of code:

var address = await _customerService.GetCustomerAddressAsync(customer.Id, addressId);
...
customer.BillingAddressId = address.Id;

(FYI  https://github.com/nopSolutions/nopCommerce/issues/4601 )
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.