Shopify themes, liquid, logos, and UX
Hi There, I have the Ella theme. When I click the "add to cart" button, I would like for it to redirect me right to checkout, and skip the cart page since my store only has one item. Please let me know how I can achieve this.
Hi @gltl
You can check if your theme has that settings in Online Store > Themes > Customize > Theme settings > Cart
- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
Hi, it does, but it only has the redirect to cart page setting. I want to be able to redirect to checkout.
Could you share your product page link so I can check?
- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
Please add this code to Custom Liquid block below your Buy buttons on your Online store > Themes > Customize > Products > Default product and hide your default Pre-oder button
<button type="button" class="product-form__submit button button--primary an-horizontal-shaking button-text-change" onclick="addToCartAndCheckout()">Pre-order</button>
<script>
async function addToCartAndCheckout() {
const quantity = document.querySelector('input[name="quantity"]').value || 1;
const variantId = {{ product.variants.first.id }};
// Add the item to the cart
await fetch('/cart/add.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ id: variantId, quantity: quantity })
});
// Redirect to checkout
window.location.href = '/checkout';
}
</script>
- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
How can I still display the content below the pre-order button? The expected ship date and purple dot link.
So please update code and add it to Custom liquid code above 'Buy buttons'
<button type="button" class="product-form__submit button button--primary an-horizontal-shaking button-text-change" onclick="addToCartAndCheckout()">Pre-order</button>
<script>
async function addToCartAndCheckout() {
const quantity = document.querySelector('input[name="quantity"]').value || 1;
const variantId = {{ product.variants.first.id }};
// Add the item to the cart
await fetch('/cart/add.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ id: variantId, quantity: quantity })
});
// Redirect to checkout
window.location.href = '/checkout';
}
</script>
<style>
.product-form__buttons button { display: none !important; }
<style>
- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
That made everything disappear. I would like to display everything as normal (as is shown now in the link). The only thing I want to change is the redirect to the checkout.
Please add the code so I can check
- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
I'd rather use cart permalinks here -- do not need to wait for fetch to complete.
Given they offer only one product no need to worry about what's already in cart.
Like i suggested here
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024