I'm using How to add additional fees to different products in WooCommerce cart answer code (part 2). This code is to add additional fees to the products that are described with their IDs.
Of that existing answer I have replaced:
// Settings
$settings = array(
array(
'product_id' => 30,
'amount' => 5,
'name' => __( 'Additional service fee', 'woocommerce' ),
),
array(
'product_id' => 813,
'amount' => 10,
'name' => __( 'Packing fee', 'woocommerce' ),
),
array(
'product_id' => 815,
'amount' => 15,
'name' => __( 'Another fee', 'woocommerce' ),
),
);
With
// Settings
$settings = array(
array(
'product_id' => __(123, 456, 789),
'amount' => 10,
'name' => __( 'Additional service fee', 'woocommerce' ),
),
array(
'product_id' => __(987, 654, 321),
'amount' => 20,
'name' => __( 'Additiona packing fee', 'woocommerce' ),
),
array(
'product_id' => __(445, 556, 555),
'amount' => 30,
'name' => __( 'Additinal specific fee', 'woocommerce' ),
),
);
At the moment, if I add two products that are in the same "additional fee" category, for example, "'Additional service fee'" only shows me the amount once and does not count it.
My question is how to change the code so that by adding more than one product that is in the same "additional fee" category - to consider the sum of the fee for the category.