I have been working on a custom-controller for checkout and I got it working except for one problem.
When I deselect the "this variant is shippable" option and I run my controller without shipping-code it works fine: I can see the invoices as fulfilled in the paid invoices.
Now I'm trying to add shipping.
So I select the "this variant is shippable" option for my products. I have the default warehouse and catalog selected at shipping information of the products.
I have a fixed rate shipping provider with a range defined.
In my controller I add next snippet:
var wareHouse = MerchelloContext.Current.Services.WarehouseService.GetDefaultWarehouse();
var shipmentService = MerchelloContext.Current.Services.ShipmentService;
var shipmentStatus = shipmentService.GetShipmentStatusByKey(Constants.ShipmentStatus.Quoted);
var shipment = shipmentService.CreateShipment(shipmentStatus, wareHouse.AsAddress(), shippmentAddress, basket.Items);
var quote = MerchelloContext.Current.Gateways.Shipping.GetShipRateQuotesForShipment(shipment, false);
But when I run it and check the value of quote, the enumerable within is always empty.
I have found this code, which gives me my shipmentRateQuote:
var shipment = basket.PackageBasket(shippmentAddress).FirstOrDefault();
if (shipment != null)
{
var shipmentRateQuotes = shipment.ShipmentRateQuotes().ToList();
if (shipmentRateQuotes.Any())
{
checkoutManager.Shipping.SaveShipmentRateQuote(shipmentRateQuotes.First());
}
}
So I am one step further.
But I still have to fulfill my order in the backoffice, however in my project shppings are taken care of externally.
I only need them as reference, so I would like to create the shippment during checkout. Again it is hard to find the necessary steps. How do I create a shipment and connect it to the order?
Merchello - shipment in custom checkout
Hi,
I have been working on a custom-controller for checkout and I got it working except for one problem. When I deselect the "this variant is shippable" option and I run my controller without shipping-code it works fine: I can see the invoices as fulfilled in the paid invoices.
Now I'm trying to add shipping. So I select the "this variant is shippable" option for my products. I have the default warehouse and catalog selected at shipping information of the products. I have a fixed rate shipping provider with a range defined.
In my controller I add next snippet:
But when I run it and check the value of quote, the enumerable within is always empty.
I also tried the next one:
but this also is empty. What am I doing wrong?
Hi,
I have found this code, which gives me my shipmentRateQuote:
So I am one step further. But I still have to fulfill my order in the backoffice, however in my project shppings are taken care of externally. I only need them as reference, so I would like to create the shippment during checkout. Again it is hard to find the necessary steps. How do I create a shipment and connect it to the order?
OK, I solved it by using the ShipmentApiController like in this example
And to fullfil the order manually, I added:
For now this seems to work...
is working on a reply...