Automatically add free item by quantity

Hi, I have an item on our menu that is added automatically when an item is added. So every single item A added will receive item B for free. The automation works fine when item A is added one by one, but if we use the keyboard to add multiple items A (ie we choose 5 and item A), then only 1 item B is automatically added, which should be 5 item B to match. Is there a way to add item B based on the quantity of item A?

Can you show some screen shots of your setup?