0

I am trying to make custom alert messages in Portuguese on a Adobe Business Catalyst website using this code from : Customizing Online Shop Alert Message Strings

and also customize the online shop layout strings like "Shopping cart is empty! continue shopping " and "1 item(s), Total: €12,00 VIEW CART" to "Carrinho de compras vazio! continuar as compras." and "1 item(s), Total:€ 12,00 VER CARRINHO DE COMPRAS"using this piece of code i found somewhere on the Adobe forum too:

<script type="text/javascript">
   var ele = GetElementsByClass('cartLink');
   if(ele[0])  ele[0].innerHTML = 'O CARRINHO DE COMPRAS EST&Agrave; `enter code here`VAZIO!';// replace with your own message!
   function UpdateProductExtras(c, p, res) {
  document.getElementById('catCartDetails').innerHTML = 'O carrinho de compras est&aacute; vazio! <a href="/catalogos">VOLTAR</a>'; // replace with your own message!
   }
   /*
  var ele = GetElementsByClass('cartSummaryItem');
  if(ele[0]) ele[0].innerHTML = 'Carrinho de compras vazio.';// replace with your own message!
  function UpdateProductExtras(c, p, res) {
  document.getElementById('cartSummaryItem').innerHTML = 'Carrinho de compras vazio.'; // replace with your own message!
  }*/This one works but if we click to buy something then this doesn't show: "1 item(s), Total: €12,00 VIEW CART"


   var ele = GetElementsByClass('cartSummaryLink');
   if(ele[0])  ele[0].innerHTML = 'Ver carrinho de compras >';// replace with your own message!
   function UpdateProductExtras(c, p, res) {
  document.getElementById('cartSummaryLink').innerHTML = 'Ver carrinho de compras >'; // replace with your own message!
   }
   </script>

The piece of code seems to work, but everytime BC fires a pop up window, like wen we add a new product to the shopping cart or wen we hit the empty shopping cart button, they go back to the original strings in English, and only when we refresh the browser or move to another catalog and continue shopping, the messages go back to Portuguese. How to Fix this?

The same happens to the pop up window messages from the js file from Customizing Online Shop Alert Message Strings, they only change to Portuguese if we refresh the browser,every time we make a new action, the pop up window messages go back to English.

This is the link to the template i am working on.

Cœur
  • 37,241
  • 25
  • 195
  • 267

3 Answers3

0

If you haven't already, be sure to include this script in the Overall shop layout rather than the page template.

When a product is added or removed, the overall layout will be loaded again.

At the moment, it looks like your code may be inside the page template just before the body tag.

Neido
  • 181
  • 7
0

When adding/removing items to cart BC ajax refresh some divs *overall shop layout and cart summary), It doesn't reload the whole page, so any external js will stop working.

I solve this kind of issues by adding a listener to the divs that are refreshed afer adding/removing items to/from cart to triger any JS needed if any of these divs have change.

Hope it helps

Tyra Pululi
  • 436
  • 1
  • 7
  • 19
0

Your first link at the top "Customizing Online Shop Alert Message Strings" is the best option to achieve what you are looking for.

Include this example at the end of your body tag of your template:

Works for me!

<script type="text/javascript">
Oshoplang = { 
InvalidQuantity:    ' adicione uma quantidate.\n\nTente Novament. ',
CartEmpty:          ' O carrinho de compras esta vazio!. \n\n<br/><br/><a class="message-button" onClick="redirectOffCart();" href="#">Continue as compras</a> ',
CartUpdateSuccess:  ' Ordem atualizada.\n\nThank you. ',
InvalidShip:        ' Escolha um modo de envio.\n\nTente Novament. ',
            }
</script>
Ricardo Alves
  • 561
  • 1
  • 5
  • 21