Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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 also tried the next one:
var quotes = shipment.ShipmentRateQuotes();
but this also is empty.
What am I doing wrong?
I have found this code, which gives me my shipmentRateQuote:
var shipment = basket.PackageBasket(shippmentAddress).FirstOrDefault();
if (shipment != null)
var shipmentRateQuotes = shipment.ShipmentRateQuotes().ToList();
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:
foreach (OrderLineItem orderItem in order.Items)
orderItem.ShipmentKey = shipmentDisplay.Key;
order.OrderStatus = orderService.GetOrderStatusByKey(Constants.OrderStatus.Fulfilled);
For now this seems to work...
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted