With the Translate & Adapt app, you can add translations to your store for products, collections, blog posts, policies, and pages.
Hi,
I am using the Translate & Adapt Shopify app. Currently there are two languages on the website: English (Default) and Norwegian. The website has been successfully localized in Norwegian, except for the "Buy it now" button.
This record does not exist when searching for it in the store's content within the Translate & Adapt app. Is there a way to translate this button? 🙂
Solved! Go to the solution
This is an accepted solution.
Hi @hamarsen ,
I have custom written a JS solution for this.
Follow these Steps:
1) Go to Online Store
2) Edit Code
3) Find theme.liquid file
4) Add the following code just above </body> tag
{% if request.locale.iso_code == "no" %}
<style>
[data-testid="Checkout-button"] {
display: none!important;
}
[data-testid="Checkout-button"].show {
display: block!important;
}
</style>
<script>
let timer = 0;
const maxTime = 10000;
const intervalDuration = 100;
const searchCheckoutButton = () => {
const checkoutButton = document.querySelector('[data-testid="Checkout-button"]');
if (checkoutButton) {
checkoutButton.innerText = "Kjøp nå";
checkoutButton.classList.add('show');
clearInterval(intervalId);
console.log('Found');
} else if (timer >= maxTime) {
clearInterval(intervalId);
console.log('Time limit reached. Button not found.');
} else {
timer += intervalDuration;
}
};
const intervalId = setInterval(searchCheckoutButton, intervalDuration);
</script>
{% endif %}
If you require further help to optimize your store, please don't hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!
Best Regards,
Makka
For quick response - Message Me
Increase Xmas sales with BOGO+ Easy Free Gift Upsell. Get 30% OFF for 3 months with code "BFWIZZ30".
This is an accepted solution.
Hi @hamarsen ,
Please replace the previous code with the new one and see if this works.
{% if request.locale.iso_code == "no" %}
<style>
[data-testid="Checkout-button"] {
display: none!important;
}
[data-testid="Checkout-button"].show {
display: block!important;
}
</style>
<script>
const m_intervalDuration = 50;
const m_searchCheckoutButton = () => {
const m_checkoutButton = document.querySelector(
'[data-testid="Checkout-button"]'
);
if (m_checkoutButton && m_checkoutButton.innerText == "Buy it now") {
m_checkoutButton.innerText = "Kjøp nå";
setTimeout(function () {
m_checkoutButton.classList.add("show");
}, 500);
console.log("Found");
}
};
const m_intervalId = setInterval(m_searchCheckoutButton, m_intervalDuration);
</script>
{% endif %}
For quick response - Message Me
Increase Xmas sales with BOGO+ Easy Free Gift Upsell. Get 30% OFF for 3 months with code "BFWIZZ30".
This is an accepted solution.
Hi @hamarsen ,
I have created a new CSS to achieve this translation. Can you replace the previous code with this new one and check if this works.
{% if request.locale.iso_code == "no" %}
<style>
.product-form__buttons [data-testid="Checkout-button"] {
color: transparent;
}
.product-form__buttons [data-testid="Checkout-button"]:after {
content: "Kjøp nå";
color: rgb(var(--color-button-text));
display: flex;
align-items: center;
justify-content: center;
}
</style>
{% endif %}
This works good on my test store [https://mangit.myshopify.com/no/products/product-1?variant=35864135958681]
For quick response - Message Me
Increase Xmas sales with BOGO+ Easy Free Gift Upsell. Get 30% OFF for 3 months with code "BFWIZZ30".
Hi @hamarsen ,
Bu default, we cannot update the buy now text. However, I have comeup with a workaround to dynamically change it on multiple language. Can you provide me with the link to your store and also the translated text?
For quick response - Message Me
Increase Xmas sales with BOGO+ Easy Free Gift Upsell. Get 30% OFF for 3 months with code "BFWIZZ30".
Hi @makkaomakka,
I could be interested in hearing more about this. The link is www.handtverk.com and the button should say "Kjøp nå" instead of "Buy it now" when Norwegian is selected as a language.
This is an accepted solution.
Hi @hamarsen ,
I have custom written a JS solution for this.
Follow these Steps:
1) Go to Online Store
2) Edit Code
3) Find theme.liquid file
4) Add the following code just above </body> tag
{% if request.locale.iso_code == "no" %}
<style>
[data-testid="Checkout-button"] {
display: none!important;
}
[data-testid="Checkout-button"].show {
display: block!important;
}
</style>
<script>
let timer = 0;
const maxTime = 10000;
const intervalDuration = 100;
const searchCheckoutButton = () => {
const checkoutButton = document.querySelector('[data-testid="Checkout-button"]');
if (checkoutButton) {
checkoutButton.innerText = "Kjøp nå";
checkoutButton.classList.add('show');
clearInterval(intervalId);
console.log('Found');
} else if (timer >= maxTime) {
clearInterval(intervalId);
console.log('Time limit reached. Button not found.');
} else {
timer += intervalDuration;
}
};
const intervalId = setInterval(searchCheckoutButton, intervalDuration);
</script>
{% endif %}
If you require further help to optimize your store, please don't hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!
Best Regards,
Makka
For quick response - Message Me
Increase Xmas sales with BOGO+ Easy Free Gift Upsell. Get 30% OFF for 3 months with code "BFWIZZ30".
Thank you so much! This did the trick 😍
Hello Makka,
I have found an issue with the implementation. After I added products variants (in this case different languages of the digital product), the buy button disappears after switching. The user can still add the product to the cart and the button reappears when refreshing. WDYT? 🙂
This only occurs on the Norwegian version of the site.
https://handtverk.com/products/rekke-guide?variant=42040727929015
Hey @hamarsen , 'Buy it now' is an unusual string and is managed centrally by Shopify. We aim to add translations in every language. Norwegian has two versions on Shopify, just 'Norwegian' and 'Norwgian (Bokmål)' - which are you using? We should be able to deploy a fix from here.
To learn more visit the Shopify Help Center or the Community Blog.
Hi @richbrown_staff! That is good to hear. I am using the just "Norwegian" one.
Btw, I also expect this is the one most common in use in Norway as this is default Norwegian, which equals Norwegian (Bokmål).
This is an accepted solution.
Hi @hamarsen ,
Please replace the previous code with the new one and see if this works.
{% if request.locale.iso_code == "no" %}
<style>
[data-testid="Checkout-button"] {
display: none!important;
}
[data-testid="Checkout-button"].show {
display: block!important;
}
</style>
<script>
const m_intervalDuration = 50;
const m_searchCheckoutButton = () => {
const m_checkoutButton = document.querySelector(
'[data-testid="Checkout-button"]'
);
if (m_checkoutButton && m_checkoutButton.innerText == "Buy it now") {
m_checkoutButton.innerText = "Kjøp nå";
setTimeout(function () {
m_checkoutButton.classList.add("show");
}, 500);
console.log("Found");
}
};
const m_intervalId = setInterval(m_searchCheckoutButton, m_intervalDuration);
</script>
{% endif %}
For quick response - Message Me
Increase Xmas sales with BOGO+ Easy Free Gift Upsell. Get 30% OFF for 3 months with code "BFWIZZ30".
Thank you! It works, although the button flickers. You can test it here: https://handtverk.com/products/rekke-guide?variant=42041497321655
This is an accepted solution.
Hi @hamarsen ,
I have created a new CSS to achieve this translation. Can you replace the previous code with this new one and check if this works.
{% if request.locale.iso_code == "no" %}
<style>
.product-form__buttons [data-testid="Checkout-button"] {
color: transparent;
}
.product-form__buttons [data-testid="Checkout-button"]:after {
content: "Kjøp nå";
color: rgb(var(--color-button-text));
display: flex;
align-items: center;
justify-content: center;
}
</style>
{% endif %}
This works good on my test store [https://mangit.myshopify.com/no/products/product-1?variant=35864135958681]
For quick response - Message Me
Increase Xmas sales with BOGO+ Easy Free Gift Upsell. Get 30% OFF for 3 months with code "BFWIZZ30".
Amazing! This works perfectly. Thanks again!
User | RANK |
---|---|
2 | |
2 | |
2 | |
1 | |
1 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023