Shopify themes, liquid, logos, and UX
Hi All,
Been searching the forums and net for almost 2 hours and there are all kinds of solutions but it only solves 1 aspect of the problem.
For starters:
Im using the debut theme.
I've added the ADD TO CART button to my collections.
I've added the ajax code to my header, and product cart codes.
I've solved the adding to cart from a product page not redirecting to the cart.
I have a featured collection on my main page with add to cart buttons below each item.
I'm trying to not have it redirect to the product page when adding to cart on home page via the featured collection.
How do I do that?
URL is: www.galingdyan.com
Password: Test123
I'm at my wits end.
Thanks in advance!
Solved! Go to the solution
This is an accepted solution.
Hello @GalingDyan
please add code Snippets/product-card-grid.liquid bottom of the file.
<form action="/cart/add" data-productid="{{product.id}}" method="post" class="product-form__item product-form__item--submit product-form__item--payment-button product-form__item--no-variants" id="AddToCartForm">
<input type="hidden" name="id" value="{{ product.variants.first.id }}" />
<input type="hidden" name="return_to" value="back" />
<input type="submit" value="Add to cart" id="addToCart" class="btn product-form__cart-submit btn--secondary-accent"/>
</form>
Hope this will work for you.
Thanks!
Hello,
Your store is password locked. Kindly share the password.
Thank you!
Sorry! I just added the password I forgot it was locked since this is before launch. : )
Hey @GalingDyan
Find this code In asset->theme.js->find "$.post(params)".
If your theme contains this then follow this:
add location.href="/cart";
So it looks like:
$.post(params)
.done(
function(item) {
this._hideErrorMessage();
this._setupCartPopup(item);
location.href="/cart";
}.bind(this)
)
Hope this will work for you.
Thanks!
Thanks for the swift reply.
added but still takes me to the product page when adding to cart on the main page.
See code above if I did it right. 🙂
Hey @GalingDyan,
Are you using ajaxsify?
Please share your button code.
Thanks!
Yup using ajaxify for the cart function.
For the button code:
<form method="post" action="/cart/add"> <input type="hidden" name="id" value="{{ product.variants.first.id }}" /> <input min="1" type="number" id="quantity" name="quantity" value="1"/> <input type="submit" value="Add to cart" class="btn" /> </form>
added this at the end of product-card-grid,liquid
This is an accepted solution.
Hello @GalingDyan
please add code Snippets/product-card-grid.liquid bottom of the file.
<form action="/cart/add" data-productid="{{product.id}}" method="post" class="product-form__item product-form__item--submit product-form__item--payment-button product-form__item--no-variants" id="AddToCartForm">
<input type="hidden" name="id" value="{{ product.variants.first.id }}" />
<input type="hidden" name="return_to" value="back" />
<input type="submit" value="Add to cart" id="addToCart" class="btn product-form__cart-submit btn--secondary-accent"/>
</form>
Hope this will work for you.
Thanks!
That work fantastically!
You are a legend!
I hope this helps others as well.
Just wanted to say a massive THANK YOU!
I'm using the Simple theme and had managed to get my add to cart button working on my collection pages but it kept redirecting to the cart. I know hardly anything about coding. Your response sorted the cart redirect out so customers can remain in the collection and keep shopping.
You're a total legend!
This did not work for me. I am having the exact same issue, tried different codes but the button still takes me to the product page!
Any ideas?
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024