My buy now button adds the product to the cart, and everything from the cart to the checkout

Topic summary

A user is seeking help to modify their “Buy Now” button code. Currently, the button adds the selected product to the cart and then redirects to checkout with all cart items included.

Desired Behavior:

  • The button should bypass the cart entirely
  • Only the specific product from the current page should proceed to checkout
  • Other items already in the cart should be excluded from this transaction

Technical Context:
The provided code shows a JavaScript event listener that:

  1. Captures the “Buy Now” button click
  2. Submits product data to Shopify’s /cart/add.js endpoint
  3. Redirects to /checkout

The issue is that the current implementation adds the product to the existing cart before checkout, rather than creating an isolated checkout session for just that product. No solutions or responses have been posted yet.

Summarized with AI on November 22. AI used: claude-sonnet-4-5-20250929.

Could my code be edited so that only the product on the page is checked out and not the entire cart?



Buy Now