How to redirect to the checkout page with name="checkout"

How to redirect to the checkout page with name="checkout"

eduardocoello
Tourist
9 2 2

I have two buttons inside the product page "add to cart" and "buy now" buttons. The "add to cart" works fine but the "buy now" is redirecting me back to the cart and i don't want that. I would like users to be sent to the checkout page when they click to click on this button from the product page.

Thanks.

```

{% form 'product', product %}
            {% if product.variants.size == 1 %}
                {% assign variant = product.variants.first %}
                    {% if variant.available %}
                        <input type="hidden" name="id" value="{{ variant.id }}">
                    {% else %}
                        <p>this variant is unavailable.</p>
            {% endif %}
           
            {% else if product.variants.size > 1 %}
                <select name="id">
                    {% for variant in product.variants %}
                        <option value="{{ variant.id }}">
                            {{ variant.title }}
                        </option>
                    {% endfor %}
                </select>
            {% endif %}
   
            <div>
                <button type="submit">
                    Add to cart
                </button>

                <button type="submit" name="checkout">
                    Buy Now
                </button>
            </div>
        {% endform %}
```
Replies 0 (0)