Home Forums Add-ons Repeater Field Sum Repeater fields Reply To: Sum Repeater fields

  • Thanks John, Allison.

    Unfortunately they didn’t do the trick. It might help if I reword my question with a real example.

    I’m trying to make a table that shows the total number of products shipped across all shipments.

    Shipment ‘123’ has the following products:
    Baseball Cap * 1
    T-Shirt * 2

    ‘Shipment’ is my CPT and my subfields within the ‘products’ repeater are ‘product_name’ and ‘product_quantity’.

    John’s code seems like it would take the total quantity of ALL products shipped, not the quantity of each particular product.

    $total_items = 0;
    if (have_rows('shipment')) {
      while (have_rows('shipment')) {
        $total_items += get_sub_field('product_quantity');
    echo $total_items;

    Allison’s code seems like it should work but doesn’t refer to the ‘shipments’ CPT, so I’m not sure how it knows where to look for the ‘products’ repeater fields.

    Thanks for the help anyway!