We have an merchello setup on version 2.1 and it's working fine if we use the country PT as shipping address. When we change the country code to es or uk the following line of code returns null.
var shipment = Basket.PackageBasket(shippingAddress).FirstOrDefault();
We have the providers configured for each of this countries the same way, off course different prices. I've looked into bazar code to check the differences and don't see many diferences in there.
if (!ModelState.IsValid)
return CurrentUmbracoPage();
var checkoutManager = Basket.GetCheckoutManager();
var customerManager = checkoutManager.Customer;
var paymentManager = checkoutManager.Payment;
var shippingManager = checkoutManager.Shipping;
// Clear Shipment Rate Quotes
shippingManager.ClearShipmentRateQuotes();
// Get the shipping address
var shippingAddress = customerManager.GetShipToAddress();
if (shippingAddress == null)
{
var customer = ((ICustomer)CurrentCustomer);
shippingAddress = customer.Addresses.First().AsAddress("Shipping Address");
shippingAddress.Email = customer.Email;
shippingAddress.Name = customer.FullName;
checkoutManager.Customer.SaveBillToAddress(shippingAddress);
checkoutManager.Customer.SaveShipToAddress(shippingAddress);
}
var shipment = Basket.PackageBasket(shippingAddress).FirstOrDefault();
// get the quote using the "approved shipping method"
var quote = shipment.ShipmentRateQuoteByShipMethod(model.ShipMethodKey);
// save the quote
shippingManager.SaveShipmentRateQuote(quote);
before this step, cause we have a view to define the shipping address we are saving it to basket this way.
if (!ModelState.IsValid)
return CurrentUmbracoPage();
Shipment null when i use a different shipping country address
Hi Rusty,
We have an merchello setup on version 2.1 and it's working fine if we use the country PT as shipping address. When we change the country code to es or uk the following line of code returns null.
var shipment = Basket.PackageBasket(shippingAddress).FirstOrDefault();
We have the providers configured for each of this countries the same way, off course different prices. I've looked into bazar code to check the differences and don't see many diferences in there.
before this step, cause we have a view to define the shipping address we are saving it to basket this way.
if (!ModelState.IsValid) return CurrentUmbracoPage();
i know the information is not much, but maybe you have a clue of what's missing here.
Thanks, Marco
I think you may be running into a bug that was fixed in 2.2 -
In your line:
Try changing it to
Thks a lot Rusty it was that!
is working on a reply...