{"id":11871,"date":"2019-07-21T13:41:35","date_gmt":"2019-07-21T11:41:35","guid":{"rendered":"https:\/\/pi3g.com\/?p=11871"},"modified":"2019-07-21T13:41:35","modified_gmt":"2019-07-21T11:41:35","slug":"shopify-langify-modify-checkout-link","status":"publish","type":"post","link":"https:\/\/pi3g.com\/de\/shopify-langify-modify-checkout-link\/","title":{"rendered":"Shopify &amp; Langify \u00e4ndern den Checkout-Link"},"content":{"rendered":"<h1>Shopify checkout is multilingual<\/h1>\n<p>The shopify checkout is multilingual:<\/p>\n<p><a href=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/07\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"797\" height=\"391\" title=\"image\" style=\"display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/07\/image_thumb-4.png\" border=\"0\"><\/a><\/p>\n<p><a href=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/07\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"429\" title=\"image\" style=\"display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/07\/image_thumb-5.png\" border=\"0\"><\/a><\/p>\n<p>The trick is to have a<strong> &amp;locale=en or &amp;locale=en<\/strong> at the end of the link:<\/p>\n<p><a href=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/07\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"165\" height=\"35\" title=\"image\" style=\"margin: 0px; display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/07\/image_thumb-6.png\" border=\"0\"><\/a><\/p>\n<p>You can therefore create buttons, etc. which take your user to the checkout, under the links of<\/p>\n<ul>\n<li><a href=\"https:\/\/buyzero.de\/checkout?locale=de\">https:\/\/buyzero.de\/checkout?locale=de<\/a><\/li>\n<li><a href=\"https:\/\/buyzero.de\/checkout?locale=en\">https:\/\/buyzero.de\/checkout?locale=en<\/a><\/li>\n<\/ul>\n<p>which will set the locale to the appropriate language.<\/p>\n<p>(replace <a href=\"https:\/\/buyzero.de\/\">buyzero.de<\/a> by your domain).<\/p>\n<p><\/p>\n<h1>Shopify Liquid<\/h1>\n<p>Liquid is the Shopify template language. You can do some dynamic processing server-side with it. We are going to use it to customize the links of a checkout button:<\/p>\n<p><a href=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/07\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"133\" height=\"85\" title=\"image\" style=\"margin: 0px; display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/pi3g.com\/wp-content\/uploads\/2019\/07\/image_thumb-7.png\" border=\"0\"><\/a><\/p>\n<p>Depending on the language this button should take us to the ?locale=de or the ?locale=en variant.<\/p>\n<p>The following snippet could work on shops which do NOT have langify<\/p>\n<blockquote>\n<p><a href=\"https:\/\/buyzero.de\/checkout?locale={{shop.locale\">https:\/\/buyzero.de\/checkout?locale={{shop.locale<\/a>}}<\/p>\n<\/blockquote>\n<p>On my Shopify shop, it always gives \u201cde\u201d as a result, no matter which language is selected and applied (by Langify).<\/p>\n<h1>Langify<\/h1>\n<p>Langify translates content on your page. It (I think) assigns language id\u2019s. I suspect these are individual for each shop. In my case they are as follows:<\/p>\n<ul>\n<li>ly30567 =&gt; de<\/li>\n<li>ly30568 =&gt; en<\/li>\n<\/ul>\n<p>We need to obtain the language. The hint is given in ly-static-string.liquid:<\/p>\n<blockquote>\n<p>{% assign language = cart.attributes[&#8220;language&#8221;] %}<\/p>\n<\/blockquote>\n<p>This <strong>cart.attributes[\u201clanguage\u201d] <\/strong>variable actually stores the language in the Langify way above. <\/p>\n<p>Please note, there are other variables like {{current_language}} which will yield this, but apparently not everywhere \u2013 maybe the variable is not defined at the point I was trying to use it.<\/p>\n<p><strong>cart.attributes[\u201clanguage\u201d]&nbsp; <\/strong>works for me.<\/p>\n<h1>Substitution<\/h1>\n<p>The last thing you will need to do is to replace the output of the variable with the corresponding language (<strong>de <\/strong>or <strong>en<\/strong>). This can be done as follows:<\/p>\n<blockquote>\n<p>{{cart.attributes[&#8220;language&#8221;] | replace: &#8220;ly30567&#8221;, &#8220;de&#8221; | replace: &#8220;ly30568&#8221;, &#8220;en&#8221; }}<\/p>\n<\/blockquote>\n<p>Thus the full URL for me is set up as follows:<\/p>\n<blockquote>\n<p>a href=&#8221;\/checkout?locale={{cart.attributes[&#8220;language&#8221;] | replace: &#8220;ly30567&#8221;, &#8220;de&#8221; | replace: &#8220;ly30568&#8221;, &#8220;en&#8221; }}&#8221; class=&#8221;site-header__cart small&#8211;hide&#8221;<\/p>\n<\/blockquote>\n<h1>References:<\/h1>\n<ul>\n<li><a href=\"https:\/\/shopify.github.io\/liquid\/filters\/replace\/\">https:\/\/shopify.github.io\/liquid\/filters\/replace\/<\/a><\/li>\n<li><a href=\"https:\/\/cheat.markdunkley.com\/\">https:\/\/cheat.markdunkley.com\/<\/a> = Shopify cheat sheet (for Liquid)<\/li>\n<\/ul>\n<h1>We\u2019re for hire<\/h1>\n<p>Our daily rate is 1500 \u20ac net. We will solve your problems related to anything digital (Shopify \/ ecommerce \/ coding \/ Raspberry Pi \/ JavaScript \/ Crystal Lang \/ Python \/ \u2026 ). <\/p>\n<p><a href=\"https:\/\/pi3g.com\/kontakt\/\" target=\"_blank\">Click here to get in touch now<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Shopify Checkout ist mehrsprachig Der Shopify Checkout ist mehrsprachig: Der Trick besteht darin, ein &amp;locale=en oder &amp;locale=en am Ende des Links zu haben: Sie k\u00f6nnen daher Schaltfl\u00e4chen usw. erstellen, die den Benutzer zur Kasse f\u00fchren, und zwar unter den Links von https:\/\/buyzero.de\/checkout?locale=de https:\/\/buyzero.de\/checkout?locale=en, die das Gebietsschema auf die entsprechende Sprache setzen. (ersetzen Sie buyzero.de durch...<\/p>","protected":false},"author":830,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[402],"tags":[660,665,663,661,662,664],"class_list":["post-11871","post","type-post","status-publish","format-standard","hentry","category-development","tag-bilingual","tag-langify","tag-liquid","tag-multilingual","tag-shopify-checkout","tag-translation"],"_links":{"self":[{"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/posts\/11871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/users\/830"}],"replies":[{"embeddable":true,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/comments?post=11871"}],"version-history":[{"count":1,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/posts\/11871\/revisions"}],"predecessor-version":[{"id":11872,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/posts\/11871\/revisions\/11872"}],"wp:attachment":[{"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/media?parent=11871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/categories?post=11871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pi3g.com\/de\/wp-json\/wp\/v2\/tags?post=11871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}