Sometimes I need to use a custom shipping cost for a sale.
When I manually add the shipping product line and quote the sale,
then a second line is added with the shipping product.
How I do it at the moment:
Quote the sale
Get the shipping cost line added automatically with the wrong price or 0
Go back to draft
Edit the shipping cost line added automatically
Quote again
Now the shipping cost is right.
But as I have sale amendments added, I get all the sales with a useless revision.
and we customize method “compute_shipment_cost”:
def compute_shipment_cost(self, carrier):
cost = super().compute_shipment_cost(carrier)
if self.shipment_cost_method is None:
cost = None
if self.shipment_cost_method == 'shipment':
cost = 0
if self.shipment_cost_method == 'order':
if carrier == self.carrier:
cost = self.shipment_cost
if self.carriages:
for carriage in self.carriages:
if carriage.carrier == carrier:
if carriage.cost_method is None:
cost = None
if carriage.cost_method == 'shipment':
cost = 0
if carriage.cost_method == 'order':
cost = carriage.shipment_cost
return cost
Thank you @maxx, I will use your solution.
Then again maybe my question is wrong: maybe the right solution is to use shipment_cost_method = None and add the shipping product manually…