Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Cart Shipping Lost When Registering (Commerce 11.8.2)

$
0
0

We have a process where users can complete our basket process anonymously. During this process a user can fill in a billing and delivery address with the following code

cart = cart ?? CommerceHelper.Service.GetCart(basketType);
if (cart != null)
{
   var shipment = cart.GetFirstShipment();
   if (shipment == null)
   {
      shipment = cart.CreateShipment();
      cart.AddShipment(shipment);
   }
var address = OrderGroupRepository.Service.CreateOrderAddress(cart);
AddressConverterService.Service.MapOrderAddress(address, addressData);
shipment.ShippingAddress = address;
OrderRepository.Service.Save(cart);

With the address convert code just mapping the model between ours and the underlying commerce mapping model

/// <inheritdoc />
public void MapOrderAddress(IOrderAddress address, AddressData addressData)
{
    var name = $"{addressData.Building}, {addressData.Address}, {addressData.Postcode}";
    address.Id = name;
    address.Email = addressData.Email;
    address.FirstName = addressData.FirstName;
    address.LastName = addressData.LastName;
    address.DaytimePhoneNumber = addressData.Phone;
    address.Line1 = addressData.Building;
    address.Line2 = addressData.Address;
    address.PostalCode = addressData.Postcode;
    address.CountryName = addressData.CountryName;
    address.CountryCode = addressData.CountryCode;
    address.City = addressData.Town;
    address.RegionName = addressData.County;
}

If the user then registers an account (Using starndard ASP.NET Indentity and Commerce code) the shipment.ShippingAddress is then coming back as null.

I imagine it's something to do with maybe the Cart merging but I've been unable not narrow it down. Does anyone have any knowledge around this issue?

Thanks,

Scott


Viewing all articles
Browse latest Browse all 9076

Trending Articles