You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Shopify店铺技术问询:跳过购物车直结账及添加集合页Buy now按钮

1. How to Skip the Cart and Go Straight to Checkout in Shopify

Got it, here are a few proven ways to cut out the cart page entirely, depending on your needs:

Option 1: Use Shopify's Built-In Direct Checkout

This is the easiest route if you just want a "Buy Now" button on product pages that skips the cart:

  • Head to your Shopify admin → Settings → Checkout
  • Scroll down to the Shopping cart section
  • Flip the toggle for "Allow customers to check out directly from the product page"—this adds a "Buy now" button next to your regular "Add to cart" button, which takes users straight to checkout.

Option 2: Auto-Redirect from Cart to Checkout

If you want anyone who accidentally lands on the cart page to be sent straight to checkout, edit your theme's cart template:

  • Go to Online Store → Themes → Actions → Edit code
  • Find cart.liquid (or cart-template.liquid—the exact name depends on your theme)
  • Drop this script at the bottom of the file:
window.location.href = '/checkout';

Save your changes, and now the cart page will immediately redirect to checkout.

Option 3: Modify Add-to-Cart Buttons to Point Directly to Checkout

For full control, change the form action on your add-to-cart buttons to go straight to checkout instead of the cart:

  • In your product template (like product.liquid or product-form.liquid), locate the <form> tag that handles adding items to cart
  • Swap the action="/cart/add" attribute with action="/checkout"
  • Make sure the form still includes all required fields: id (for the product variant) and quantity
2. Adding a "Buy Now" Button on Collection Pages to Add Items to Cart (or Checkout)

Adding a "Buy Now" button to your collection grid is straightforward with a bit of theme code tweaking. Here's how:

  1. Access your theme code: Shopify admin → Online Store → Themes → Actions → Edit code
  2. Find the collection product snippet: Look for files like product-grid-item.liquid, card-product.liquid, or collection.liquid—this is the file that renders each individual product in your collection grid.
  3. Add the button code:
    • Locate the existing "Add to cart" button block in that snippet
    • Paste this code right next to it (adjust the CSS classes to match your theme's styling):
    <form action="/cart/add" method="post" class="buy-now-form">
      <input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}">
      <input type="hidden" name="quantity" value="1">
      <button type="submit" class="button buy-now-button">Buy Now</button>
    </form>
    
    • If you want this button to skip the cart and go straight to checkout (matching your first request), change action="/cart/add" to action="/checkout"
  4. Style the button: Add some CSS to make it fit your theme. Pop this into your theme's base.css or theme.css file:
    .buy-now-button {
      background: #0070f3;
      color: white;
      border: none;
      padding: 8px 12px;
      margin-left: 6px;
      border-radius: 4px;
      cursor: pointer;
    }
    .buy-now-button:hover {
      background: #005bb5;
    }
    
  5. Test thoroughly: Save your changes, then visit a collection page. Click the new "Buy Now" button—should add the product to your cart (or take you to checkout if you adjusted the action).

Quick Notes:

  • If your collection has products with variants (sizes, colors, etc.), this code will use the first available variant. To handle variant selection directly in the collection grid, you'd need to add a variant picker, which is a bit more involved.
  • Always duplicate your theme before making code changes—this way you can revert if something goes wrong.

内容的提问来源于stack exchange,提问作者user49799

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:21:10