We have a plugin that rates the shipment as a whole using a flat rate.
Now let's implement a plugin that rates the shipment using a flat rate per item.

The flat_rate_per_Item plugin extends the flat_rate plugin.
In calculate rates, it multiples the rate_amount ($price->multiple()) by the number of items (2 products, quantity; 4 for each = 8).

Note that we can't implement this until the shipment interface is complete, cause there's no ShipmentInterface::getItems() yet, and there's no ShipmentItem either.

Comments

bojanz created an issue. See original summary.

swickham’s picture

Assigned: Unassigned » swickham
swickham’s picture

Work is located in this branch, just an initial commit so far while waiting for the Shipment entity to be completed - https://github.com/swickham78/commerce_shipping/tree/flat_rate_by_item

  • bojanz committed cf3098c on 8.x-2.x authored by swickham
    Issue #2826183 by bojanz, swickham: Create a flat_rate_per_item plugin
    
bojanz’s picture

Status: Active » Fixed

Completed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.