I have a Shopify store based in Singapore and set the primary market to SG as I need the payouts to be in SGD. My main customers are from China, and I want the default currency to be CNY. Right now, it switches around CNY and SGD between my devices.
I saw this at my Shopify footer.liquid file when I enabled the currency selector. I tried adding in {% assign form.current_currency.iso_code = "CNY" %} in hopes of changing the current currency of the shop to CNY, but it didn't work.
Is there any way to mimic the way the store currency is changed or to change the "current_currency" directly without requiring user input from the customers? Can't seem to find where the current currency data is stored in.
<div class="disclosure" data-disclosure-currency>
<button type="button" class="disclosure__toggle" aria-expanded="false" aria-controls="currency-list" aria-describedby="currency-heading" data-disclosure-toggle>
{{ form.current_currency.iso_code }} {%- if form.current_currency.symbol -%}{{ form.current_currency.symbol }}{%- endif -%}
{% assign form.current_currency.iso_code = "CNY" %}
</button>
Would appreciate any help I can get! :) Thanks in advance.
Related
I want to inject some custom liquid in my abandoned cart email on Shopify. Shopify has docs here saying the product_title can be found under line_items under abandoned_cart.
I naturally assume you can get the product_title with something akin to...
<p>You left {{ abandoned_checkout.line_items[0].product_title }} in your cart.</p>
But this doesn't work. What's the proper way to get the product name of the first item?
If you are working with email template for "Abandoned checkout" in notification settings, this should work:
{{ subtotal_line_items[0].product.title }}
Loop code:
{% for line in subtotal_line_items %}
{{ line.product.title }}
{% endfor %}
And here is some useful documentation here:
https://help.shopify.com/en/manual/orders/notifications/email-variables#line-item
All products for the abandoned cart will keep here: subtotal_line_items and you should operate with the Product object. So in the your case it should be:
<p>You left {{ subtotal_line_items[0].product.title }} in your cart.</p>
I would like to know how I can achieve to update the tax price given in the following image.
I inserted the following code into my price:
{%- if shop.taxes_included or shop.shipping_policy.body != blank -%}
<div class="product__tax caption rte">
{%- if shop.taxes_included -%}
{{ 'products.product.include_taxes' | t }}
<span id="taxPrice" class="product__tax caption rte" itemprop="price">
{{ product.price | times:0.19 | money }}
<br>zzgl. Versand
</span>
{%- endif -%}
Now I want to achieve that the price for the taxes update as I change the variant.
I'm pretty sure it's possible with some JS, but unfortunately I have no experience in JS.
I'll appreciate every possible answer.
I tried to insert a JS code snippet (into the global.js file) from an older shopify support ticket regarding the same thing.
$('#taxPrice').html( Shopify.formatMoney(variant.price * 0.19, moneyFormat) );
But didn't work out as expected, although it worked on the Minimal theme just fine.
This seems like it so be such a simple one but for whatever reason I can't see the forest for trees. So I have the current situation in Screenshot 1 where I have set three different variants for a product. The products are size based as ML...but for some reason all 3 variants are showing on the button instead of the one thats selected.
The code I use to pull this out currently is:
{% if current_variant.available %}
<button type="submit" name="add" class="border--none">
<span class="display--block padding--1 palette--background-color--green palette--color--white text-transform--uppercase letter-spacing--2px font-size--15px palette--color--white">
add to bag |
<strong>
{% for variant in product.variants %}
{{ variant.price | money_without_trailing_zeros }}
{% endfor %}
</strong>
</span>
</button>
{% else %}
What you are trying to achieve is not possible with Liquid only. Liquid is just a templating language that is rendered at server side. It does not update on client side.
You want to display the price in button only for the selected variant, but Liquid has no information about that on server side and you just loop through the prices of all available variants. Hence, you see all prices in your button.
To fix this, use the first available or selected variant price using Liquid and update rest using JavaScript at client-side.
Returns the variant object of the currently-selected variant if there
is a valid ?variant= query parameter in the URL. If there is no
selected variant, the first available variant is returned.
Doing so, your code will be like
<button type="submit" name="add" class="border--none">
<span class="display--block padding--1 palette--background-color--green palette--color--white text-transform--uppercase letter-spacing--2px font-size--15px palette--color--white">
add to bag |
<strong>
{{ product.selected_or_first_available_variant.price | money_without_trailing_zeros }}
</strong>
</span>
</button>
Then change price via JavaScript on variant change, that is dependent on your theme.
More information on Selected or First Available Variant
I am simply allowing to checkout out of stock product to buy. When a customer wants to buy product has inventory less than zero and clicks on view cart from ajax cart, I simply want to show message " dispatch by 7 June." in cart-template.liquid.I have applied logic as given below. If required full code ready to share.
{% if variant.inventory_quantity < 1%}
<p id="dispatch" style="color: #f48c21">Will be dispatched by June 7</p>
{{variant.inventory_quantity}}
{% endif %}
<script>console.log(variant.inventory_quantity)</script>
when I print the message in cart-template.liquid without if condition I can see this message. I found that it does not print anything inside {{}} also checked with console.log gives error as variant is not defined My query Is do I need to define variant manually? if yes how? or need to use a different liquid variable to check inventory quantity of product less than zero?
Let me know if any more are required. Thanks.
I have started printing all variant variable. I just simply added item before variant.inventory_quantity and it saves my day.
{% if item.variant.inventory_quantity < 1 %}
<p id="dispatch" style="color: #f48c21">Will be dispatched by June 7</p>
{% endif %}
I have a dev theme for a shopify store. Basically it's a child theme. I would like to get how to display the best selling products on the front page. I tried something like this but no luck maybe because the sample is outdated.
<div class="row">
{% for product in collections["all"].products | limit:12 | sort_by: 'best-seller' %}
{% include 'product-grid-item' with "all" %}
{% endfor %}
</div>
Is there any way we can create something like this? Thanks in advance.
An easy way of doing it, as sort on Shopify won't work with the value best-seller, is to create a new Collection called (for example) Best Sellers where you have all your products (you could set as the sole condition for product price to be greater than $0 if it applies on your store).
Then, set that collection sorting to By best selling on your admin dashboard.
Finally, use Liquid in a similar way as per the following:
<div class="row">
{% for product in collections.best-sellers.products | limit:12 %}
{% include 'product-grid-item' with "all" %}
{% endfor %}
</div>