How to changes the currency of fixed price in Shopify? - shopify

I want to change the currency of fixed price for currency change I've using shopify market for change the currency which is working fine but for fixed price(in green circle) to change I've using following code, its working but conversion is not accurate(you can check price for middle section), any help would be appreciated.
{% assign val = 81 %}
<span class="money">{{ val | money }}</span>

Related

Shopify get lowest price product if available in product having same title

I have duplicate products which offer same size or different size products with same title but vendors is different. I want to display products which ever cheaper in my website. So my website will always display products from one vendor only ( Which ever cheaper ). In product details page i want to check this logic to find the same title products from different vendors. I tried the below code . When i given the handle statically then it is showing other vendor products finely. I want to make it dynamic. Can anybody help me on this.
Now i want to display the lowest price product if available.
Product is having different sku,handle, price but title is same.
Please help me to show lowest price product.
{% assign some_handle = product.handle %}
{% assign custom_product = all_products[some_handle] %}
{{ product.title }} is {{ product.price | money }}, but {{ custom_product.title }} is {{ custom_product.price | money }}
i tried this code in product_template.liquid file but it is not working as expected.

Set Shopify store default currency using liquid

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.

Show Price with and without taxes into Product Page

I have a problem into a Prestashop 1.7 solution.
Into a Product page, i want to show 2 prices (include and exclude VAT)
<span itemprop="price" content="{$product.price_amount}">{$product.price}</span>
This example show price with VAT. I don't find how show price without VAT too.
Thanks
You can use {debug} in your .tpl and you will see all available variables that you can use.
Our you can use {$product|#var_dump} which will show you what sub-variables the $product variable contains
You can use {$product.price_tax_exc} variable to display price with tax excluded.
There is the displayPrice() method that you can use to format the price displayed.
But since version 1.7.6 you should use the formatPrice() method, since displayPrice is deprecated.
You can use it like this:
{block name='product_without_taxes'}
{if $priceDisplay != 1}
<p class="product-without-taxes">{l s='%price% tax excl.' d='Shop.Theme.Catalog' sprintf=['%price%' => Context::getContext()->currentLocale->formatPrice($product.price_tax_exc, $currency.iso_code)]}</p>
{/if}
{/block}
This way you'll have the price formatted with the current currency and the tax excl. text. For example in French it will display 10,00 € HT, 'HT' meaning 'tax excluded'

Shopify liquid : cart-template variant is not defined

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 %}

Metafields in Shopify: Trying to display Final Sale message for products that are 60% off

In my customized Shopify theme, a "Final Sale" message displays for any product that is 70% off using the following code:
{% assign finalSale = product.metafields.details.final_sale | upcase %}
{% if finalSale == 'TRUE' %}
<p style="color: #B21F1F;">
This item is final sale -- no returns or exchanges are accepted.
</p>
{% endif %}
I am trying to change this so it displays the Final Sale message when the product is 60% off. My theme is using the Metafields 2 app and I do see the active metafield called "final_sale" under the "Configure Product Metafields" page but I don't see where I can adjust the percentage that is assigned to this custom metafield...Does anyone know where I can find this?
The 60% figure isn't anywhere in this code, and isn't part of the theme at all. The percentage comparison is being done when the metafield gets assigned to TRUE. It's only possible to read metafields in liquid, though—you can't write to them there. You'd definitely need to look for code that sets the metafield elsewhere; perhaps as part of a custom app.
I don't think you need the metafield for this case at all, though. You could set up the logic right in liquid using product.price attributes and the math filters.
It would look something like this in liquid:
if compare_at_price | minus price | divided_by compare_at_price >= 0.6
One thing to pay attention to with this approach is Shopify's math filters rounding to the nearest integer at times, but you can fix that by multiplying by 100 before you start.
assign sale_amount = compare_at_price | minus price | times 100
assign adjusted_compare_price = compare_at_price | times 100
if sale_amount | divided_by adjusted_compare_price >= 60
The actual implementation might need to be a little more complex than this depending on how you use variants and variant pricing, plus this example can't handle the case where "price" is the original and "compare at" is the sale amount. Those can also be handled with liquid's logic. Here are the relevant liquid references to help you build this out further if needed:
https://help.shopify.com/themes/liquid/objects/product
https://help.shopify.com/themes/liquid/filters/math-filters