Updated cart insertion logic for URLs