Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • iiii 10 posts 108 karma points
    1 week ago
    iiii
    0

    PackageBasket null shipment

    Hello,

    I'm using packageBasket method to get shipment and to get the shipment rates. But for some reason the returning shipment is always null (ie the returning ienumerable is empty).

    What are the conditions so it returns a not null shipment?

    What I've done:

    • have defined a shipping address
    • have items in the cart/basket
    • user is logged in
    • have Shipping Countries defined
    • have shipping providers defined

    my code:

    var shipAddress = _checkoutManager.Customer.GetShipToAddress();
    var shipment = _basket.PackageBasket(shipAddress).FirstOrDefault();
    var shipmentRateQuotes = shipment.ShipmentRateQuotes();
    

    THANK YOU! :)

  • Tolu Jemilua 28 posts 142 karma points
    1 week ago
    Tolu Jemilua
    0

    did you do:

      _checkoutManager.Customer.SaveShipToAddress(someaddress);
    
  • iiii 10 posts 108 karma points
    7 days ago
    iiii
    0

    yes I did

    public void SetDummyShippingAddress()
        {
            var shippingAddress = new AddressModel();
            shippingAddress.Address1 = ...
            ....
            _checkoutManager.Customer.SaveShipToAddress(CreateAddress(shippingAddress));
        }
    
  • Tolu Jemilua 28 posts 142 karma points
    7 days ago
    Tolu Jemilua
    0

    What does Create Address look like?

  • iiii 10 posts 108 karma points
    7 days ago
    iiii
    0

    It just converts my AddressModel to one Merchello.Core.Models.IAddress address.

    private IAddress CreateAddress(AddressModel model)
    {
                var address = new Address();
                address.Address1 = model.Address1;
                ...
                return address;
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft