Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
I'm wondering if it's possible with a plugin or a simple way to redirect the "button add to cart/buy" to an other url?
Or if it's more easy, the products that i want to redirect will be on "pre-order", so if there is a plugin that remplace the button "add to cart" by "pre-order + redirect to other website" will be the best solution.
I want to made this only on few products (maybe 10), it's not for all my product.
I use the Dawn theme.
Thank you 😉
Solved! Go to the solution
This is an accepted solution.
@Julianinho No, it will works only if the custom URL is same for all products. If you want to use different custom URL for each product, we can use metafields instead of tags. To create metafields and use it for each product, please follow below steps and let me know whether it is helpful for you.
{% if product.metafields.custom.custom_url != blank %}
<a href="{{ product.metafields.custom.custom_url }}" class="button custom_url">Pre-order</a>
{% endif %}
{% if product.metafields.custom.custom_url != blank %}
{%- style -%}
.custom_url {
width: 100%;
margin: 0px !important;
}
.product__info-container .product-form {
margin: 0px !important;
}
.shopify-payment-button {
display: none !important;
}
{%- endstyle -%}
{% endif %}
@Julianinho Please follow the below steps to add the custom URL for the specific products using the new custom button. Let me know whether it is helpful for you.
{% if product.tags contains 'pre-order-product' %}
<a href="your_custom_url" class="button custom_url">Pre-order</a>
{% endif %}
{% if product.tags contains 'pre-order-product' %}
{%- style -%}
.custom_url {
width: 100%;
margin: 0px !important;
}
.product__info-container .product-form {
margin: 0px !important;
}
/* CSS code to hide the buy button */
.shopify-payment-button {
display: none !important;
}
{%- endstyle -%}
{% endif %}
Thank you for your help 🙂
I will try this!!
This solution can work if the custom url I want is different for each product?
This is an accepted solution.
@Julianinho No, it will works only if the custom URL is same for all products. If you want to use different custom URL for each product, we can use metafields instead of tags. To create metafields and use it for each product, please follow below steps and let me know whether it is helpful for you.
{% if product.metafields.custom.custom_url != blank %}
<a href="{{ product.metafields.custom.custom_url }}" class="button custom_url">Pre-order</a>
{% endif %}
{% if product.metafields.custom.custom_url != blank %}
{%- style -%}
.custom_url {
width: 100%;
margin: 0px !important;
}
.product__info-container .product-form {
margin: 0px !important;
}
.shopify-payment-button {
display: none !important;
}
{%- endstyle -%}
{% endif %}
Thank you for your help 🙂
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024