Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #2
swickham CreditAttribution: swickham at Acro Commerce commentedComment #3
swickham CreditAttribution: swickham at Acro Commerce commentedWork 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
Comment #5
bojanz CreditAttribution: bojanz at Centarro commentedCompleted. Thanks!