Imagine a $38 basket with free delivery starting at $40. Adding a $4 notebook takes your total to $42.
If delivery would have cost $6, your original order was $44. Adding the notebook saves $2.
If delivery was only $3, your original order was $41. Now the notebook costs you an extra dollar. The delivery fee changes which option is cheaper.