BigCommerce access the users language code and currency in the template file - bigcommerce

I am wondering if it is possible to get the current users language code and currency code product.html template file. Like using a {{ }} encapsulated variable.
My current product.html look like this, but I would like to access the currency and language of the current user in this page somehow, please help.

You can access the currency code with {{currency_selector.active_currency_code}}. https://developer.bigcommerce.com/theme-objects/currency_selector
I don't believe you can get the language directly via Handlebars, but you may be able to use some indirect route looking at different properties in the settings object. For example, {{settings.country_code}}. https://developer.bigcommerce.com/theme-objects/settings

Related

How to use metafield value in Shopify APP

I have created metafield using API. Currently accessing those Metafield in shopify cart.liquid like given below -
{{shop.metafields.AnnexCloud.access_token}}
Getting correct value using above syntax.
But when I try to access Metafield through above syntax in APP files facing issue.
I am creating new shopify public APP using python. In that want access metafield using
{{shop.metafields.AnnexCloud.access_token}}
So, please help me out.
Thanks
I'm not 100% sure what you mean about accessing that metafield through your app - there are lots of places where you might be trying to use that value, so I'll try to cover a few of the bases here.
If you're trying to access the metafield in your Python code
Your app is not running on Shopify's servers and doesn't have any native concept of Liquid code. However, since your app is running on your servers with access to whatever database you've used to store the data you need, you shouldn't need to access this metafield - you should have all the information you need already saved.
That said, if your app's requirements have put you in a position where you need to read that live from the store, you can use your app's credentials to access [the-store-domain.myshopify.com]/admin/metafields.json to get metafield information into your app. You can refine your request as well - for example, [the-store-domain.myshopify.com]/admin/metafields.json?namespace=atuls-app would only return metafields where the namespace was atuls-app.
If you're trying to access the metafield in your app's front-end code
You unfortunately won't be able to put the liquid drop into any file inside of the store's /assets folder (if you're writing any files there), nor will you be able to put any Liquid inside of any assets your app loads through the content_for_header.
For the latter case, though, the scripts loaded through content_for_header would be coming from your server, so you could use any of the methods listed above to get that value injected into the script file through your server's code/logic.
For the former case, where you are adding a file to the /assets folder of a Shopify theme, you would only have access to a very limited number of Liquid variables (and unfortunately shop isn't one of them). To get around this, you would need your app's install to add a script tag to the layouts/theme.liquid file to save a global variable with the contents of your metafield. Any other scripts would then be able to access that global variable. (Note: this method comes with all the normal caveats/considerations about using global variables for things)
Hope this helps!

how do I force a field to be translated in my Odoo code?

I am developing a module for electronic invoicing, and should express the payment term in spanish, so I am setting a dictionary with all the needed fields, and when I do this:
{
...
'FmaPago': inv.payment_term.name,
...
}
The output file contains the value "name" in english. I've tried something like
_(inv.payment_term.name)
but with the same result.
How should I force the value to be expressed in a defined translation?
The field name of Payment Terms are already translatable. You can change the translation in Odoo by clicking the little button within a field in edit mode.
If you've done that correct, you have to avoid some typical mistakes at code side if you use the old API.
always pass the context
e.g. if you browse the invoice, pass the context, to get all translations correct
use partner language if you want to translate for them
Odoo is using user language in his context, to translate the web client correctly. If you print documents for customers, you want them in customer language of course...
So you maybe need to manipulate the context (key 'lang'). For new API you have to call with_context() to do that.
You must use _() for strings that you want to be able to translate.
You must make translating files *.po (as i remmember) and thats all I think.
Dont forget to check documentation link

BigCommerce Add Global Variable

I added user created custom field for customer sign up - "UPS Shipper".
And I want to show this value in Invoice email.
But it is impossible, for we can use only global variables and language variables in that email template, there is no variable for that custom added form field.
So I think it should be added a global variable for that field.
I'm not sure I'm right.
Please let me know how to add a global variable in bigcommerce.
Or let me know what I think wrong.
Best regards
Lorant
global variables are defined in the PHP and since Bigcommerce is a SaaS platform you will not be able to add that variable at all.
You may suggest that the customer can log in to their account to view the custom information if they need.

Get output of a template call in a page from MediaWiki API

I am trying to parse a page on a wikia to get additional information for a Infobox Book template that is on the page. The problem is the I can only get the template's source instead of the transformed template on the page.
I'm using the following url as a base:
http://starwars.wikia.com/api.php?format=xml&action=expandtemplates&text={{Infobox%20Book}}&generatexml=1
The documentation doesn't really tell me how to point it to a specific page and parse the transformed template from the page. Is this even possible or do I need to parse it all myself?
To expand a template with the parameters from a given page, you will have to provide those parameters. There is no way for the API to know how the template is used in different pages (it could even be used twice!).
This works:
action=expandtemplates&text={{Infobox Book|book name=Lost Tribe of the Sith: Skyborn}}
You will, of course have to keep adding all the parameters you want to parse (there are 14 in your example).
If you have templates that change automatically depending on which page they are (that is not the case here), e.g. by making use of magic words such as {{PAGENAME}}, you can add &page=Lost_Tribe_of_the_Sith:_Skyborn to your API call, to set the context the template should be expanded in.
If you to not know the parameters given, you can either:
Render the whole page with index.php?action=render&title=Lost_Tribe_of_the_Sith:_Skyborn, and parse the returned html to carve out the actual infobox
Fetch (action=query&prop=revisions) and parse the wikicode to get the parameters to the template, and supply them to the expandtemplates call
Start using an extension like Semantic MediaWiki, that allows you to treat your wiki more like a database
1 and 2 can go wrong in any number of ways, of course, as with a wiki you have, by definition, no way of knowing that the content is always entered in a consistent way.

Creating a custom message template in nopCommerce

I've written a method that collects some sales statistics that I would like to send as an email. I've searched through the project but I just can't figure out how to do this.
In the database there's a "MessageTemplates" -table with some information about the templates like "p" and "br" -tags with parameters like customer.name and so on. These templates seem to be implemented in "WorkflowMessageService" class. There's also a class called "MessageTokensProvider" but I can't see why I would need tokens as I just want the data collected from my method returned in the new mail.
Has anyone added a message template for nopCommerce before that can explain what I need to do and how it works? This would be very much appreciated.
Thank you
MessageTokensProvider is to allow certain token to be replaced with dynamic data. For example %Store.Name% will be replaced with the configured store name.
You can, of course, not use any tokens in your message template.