Add a method to get the total amount of products in a shipment.

Currently I'm using something like this:

$order_total_quantity = null;

foreach ($shipment->getItems() as $shipment_item) {
    $shipment_item_quantity = $shipment_item->getQuantity();
    $order_total_quantity  += $shipment_item_quantity;
}

Comments

bbuchert created an issue. See original summary.

bbuchert’s picture

Issue summary: View changes
bbuchert’s picture

Issue summary: View changes
bbuchert’s picture

Issue summary: View changes
bbuchert’s picture

Issue summary: View changes
mitrpaka’s picture

Status: Active » Needs review
StatusFileSize
new1.97 KB
bojanz’s picture

Status: Needs review » Needs work

The individual quantities are strings, so must the total quantity be.

I am not convinced that decimal quantities make sense in Shipping (looks like we just followed Commerce core), but that should be changed all at once, and not in this issue.

bojanz’s picture

Status: Needs work » Needs review
StatusFileSize
new2.35 KB

Updated patch.

  • bojanz committed e92a73e on 8.x-2.x authored by mitrpaka
    Issue #2940591 by bojanz, mitrpaka: Add a $shipment->getTotalQuantity()...
bojanz’s picture

Status: Needs review » Fixed

Committed #8.

Status: Fixed » Closed (fixed)

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