How to specify a custom shipping cost from sale

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:

  1. Quote the sale
  2. Get the shipping cost line added automatically with the wrong price or 0
  3. Go back to draft
  4. Edit the shipping cost line added automatically
  5. Quote again
  6. Now the shipping cost is right.

But as I have sale amendments added, I get all the sales with a useless revision.

I think there must be a better way.

We had also such problem. So we defined a new field shipment_cost on sale.

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…

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.