Mark the lines before you divide anything
Use three marks: shared, bought for the first person, and bought for the second. A pencil mark beside each amount is enough. Put the shampoo on the personal side even if it happened to be paid for with the same card as the groceries. The card identifies the payer; it does not decide who used each item.
Reconcile the whole $34
The shampoo buyer's $23 share consists of $12 plus their $11 grocery share. The other person's share is $11. Since $23 plus $11 equals $34, every line has a home. If the other person paid the whole bill, the shampoo buyer sends $23; if the shampoo buyer paid, the other person sends $11.
Handle a basket discount once
Write the two totals beside the receipt while you still remember what you bought. If a discount applied to the whole basket, agree how to divide the discount and check that the shares still add up to the amount paid.
Suppose a $2 voucher reduced the amount due to $32. One reasonable agreement is to apply it to shared groceries. Each grocery share becomes $10, so the shampoo buyer covers $22 and the other person $10. Save the particular rule you used; you need not reopen every line the next time a voucher appears.