Hi,
I need your help, please. We are using the Dawn 6.0.2 theme.
The page in question is here => https://swished.com.au/collections/tent-drink-cooler
As you can see, that is an order form. What we want to happen is, when a customer selects two items there and clicks on ADD TO CART, it should go straight to the Cart page. Unfortunately, it didn’t work that way. When you click on ADD TO CART, it goes back to the homepage.
Below is the code I copied:
{% comment %} Source: https://gist.github.com/carolineschnapp/9122054 If you are not on a collection page, do define which collection to use in the order form. Use the following assign statement, replace 'your-collection-handle-here' with
your collection handle. {% assign collection = collections.your-collection-handle-here %} Use the assign statement outside of this comment block at the top of your template. {% endcomment %}
<style>
table {
margin-left: auto;
margin-right: auto;
}
td a {
text-decoration: none;
color: black !important;
}
input.quantity {
text-align: center;
}
input.product-form__submit.button.button--primary {
border: 1px solid #e7867c;
border-radius: 10px;
width: 50%;
}
input.product-form__submit.button.button--primary:hover {
border: 1px solid #e7867c;
color: #e7867c;
background: none;
}
@media only screen and (max-width: 428px) and (min-width: 320px) {
tr:nth-child(1) > td:nth-child(2),
tr:nth-child(2) > td:nth-child(2),
tr:nth-child(3) > td:nth-child(2) {
display: none;
}
}
</style>
{% paginate collection.products by 100 %}
<form action="/cart" method="post">
{% if collection.products_count > 0 %}
<div class="text-center my-5">
<h1>{% if template contains 'page' %}{{ page.title }}{% else %}{{ collection.title }}{% endif %}</h1>
</div>
{% else %}
<h1>{% if template contains 'page' %}{{ page.title }}{% else %}{{ collection.title }}{% endif %}</h1>
{% endif %} {% if template contains 'page' and page.content.size > 0 %}
<div class="rte">
{{ page.content }}
</div>
{% elsif collection.description.size > 0 %}
<div class="rte">
{{ collection.description }}
</div>
{% endif %} {% if collection.products_count > 0 %}
<table>
<tbody>
{% for product in collection.products %} {% if product.available %} {% for variant in product.variants %} {% if variant.available %} {% unless variant.requires_selling_plan %}
<tr class="{% cycle 'pure-table-odd', '' %}">
<td>
<a href="{{ variant.url | collection }}">
<img src="{{ variant.image | default: product.featured_image | img_url: 'small' }}" alt="{{ variant.title | escape }}" />
</a>
</td>
<td>
<a href="{{ variant.url | collection }}">
{{ product.title }}{% unless variant.title contains 'Default' %} - {{ variant.title }}{% endunless %}{% unless variant.sku == blank %} - {{ variant.sku }}{% endunless %}
</a>
</td>
<td>
{{ variant.price | money }}
</td>
<td style="text-align: right;">
<input name="updates[{{ variant.id }}]" onfocus="this.select()" class="quantity field" min="0" {% unless variant.inventory_management == blank or variant.inventory_policy == 'continue' %} max="{{
variant.inventory_quantity }}" {% endunless %} type="text" value="0" tabindex="1" />
</td>
</tr>
{% endunless %} {% endif %} {% endfor %} {% endif %} {% endfor %}
</tbody>
</table>
<div id="tentCooler-bundlePage-atc" class="text-center my-5">
<input type="submit" value="Add to cart" class="product-form__submit button button--primary">
</div>
{% else %}
<p>There are no products in this view.</p>
{% endif %}
</form>
{% endpaginate %} {% if collection.products_count > 0 %}
<script>
jQuery(function ($) {
$("table .quantity:first").focus();
$("[max]").change(function () {
var max = parseInt($(this).attr("max"), 10);
var value = parseInt($(this).val(), 10) || 0;
if (value > max) {
alert("We only have " + max + " of this item in stock");
$(this).val(max);
}
});
});
</script>
{% endif %}
I truly appreciate your help. Take care