shopify liquid: plus shipping cost not working - shopify

I want to multiply the subtotal price by 21% and then add the shipping costs. Because the shipping costs are variable I use the following code.
{{ order.subtotal_price | times:1.21 | plus:shipping_method.price | money }}
But the shipping costs aren't added.
The example code in the documentation states you can divide a price by product.compare_at_price so I thought it should work the same for shipping_method.price.
What am I doing wrong? Or is it even possible?

You are using the wrong object. What you're actually looking for is order.shipping_price:
{{ order.subtotal_price | times:1.21 | plus:order.shipping_price | money }}

Related

Shopify Math liquid rounding not returning the same value when using automatic discount

I am using the following code:
{{ product.price | times: 0.90 | money_with_currency}}
I also have a 10% automatic discount enable. The price returned using the code above is not the same as the price returned using automatic discount:
Product cost |$35.49 |$34.41 |$46.59 |$52.99
price using code: |$31.94 |$30.97 |$41.93 |$47.69
10% discount in cart |$31.95 |$30.97 |$41.94 |$47.70
I would like to display the same amount using the code as the prices shown in cart
pic attached

Clear Price in Shopify

I have a problem with the price filters. I have a product that costs € 1,430.20 but I would like to obtain a value of 1430 therefore without currency, without decimals and without punctuation.
I tried with {{current_variant.price | money_without_currency | money_without_trailing_zeros}} but it doesn't work. Ideas?

Money filter giving worng asnwer in calculations liquid shopify

I am tryign to display amount after discount with my product. It works fine in calculation
For example my total price is 500 and discoutn is of 50% i get my answer 250 which is correct but when i use money filter to display currency unit i.e(Rs. ) it gives wrong answer which is Rs. 3
My code that gives correct output but without currency unit
{% assign percent_calculated = section.settings.custom_discount_title | times: productprice | divided_by: 100 %}
<span href="https://wdtcv.myshopify.com/discount/discount%2520code%2520promo" style="color:#FFDAB9" >{{ productprice |minus : percent_calculated }} </span></div>
OUTPUT
250
I want to display it as Rs. 250 but to achieve that i use "|money " filter and get wrong answer
{% assign percent_calculated = section.settings.custom_discount_title | times: productprice | divided_by: 100 %}
<span href="https://wdtcv.myshopify.com/discount/discount%2520code%2520promo" style="color:#FFDAB9" >{{ productprice |minus : percent_calculated | money }} </span></div>
OUTPUT
Rs. 3 (answer should be Rs. 250)
I got the solution which was to remove money_without_currency filter
as I used it because I was confused that liquid language requires data type casting you I used it a bit earlier.

Shopify Math logic not working properly

on my store when using custom template i got a price based on some values
Price * 2 it works
Example.
17.99 * 2
I got in cart: 35.98, this is good.
But when using:
17.99 * 0.5, should be 8.99
i got: 17.99
Why?????????? Any ideas?
Im adding as value this way:
<option value="{{ qty | times:0.50 }}" data-qua="{{ qty | times:0.50 }}">{{ inches }}m</option>
Well, i have found that due to a Shopify limitation you can not use decimals as quantity, so cannot do PRICE * 0.5
If is there a any solution to this let me know.
Sell by unit pricing. As you figured out, no shopping cart lets you sell 0.3456 of something. While you can buy .0005342 of a bitcoin, you cannot sell non-integer anything with Shopify. So adjust your formula to sell 1 thing at $.003456 or whatever... and collect your fortune that way.

how to show 4 digits after decimal in shopify?

{% assign dvtprice = currentvariant.price %}
{% assign dvtpriceprat = currentvariant.price | times :20 | dividedby :100 %}
Example: if product price is 20.33 , then Vat= (20.33*2)/100=4.066
I think that this was the way - change times: 20 to times: 20.00.
By the way your dividedby is wrong it should be divided_by.
This isn't possible with Shopify. The core code handles prices to two decimal places, so it will round if appropriate for embedded taxes.
example:
Input
{{ 183.3574456 | round: 4 }}
Output
183.3674