Need to remove decimal and cents in price?

Shopify Partner
11 0 0

As a follow up to my post here, you may want to look deeper than the collection.liquid template when trying to remove the decimal from the prices on the collection page.  Look closely at the code, and you may find that the collection price is pulling from the gallery.liquid template.

http://looptyhoops.com
0 Likes
New Member
1 0 0

Not sure where you put this in the js?

0 Likes
New Member
20 0 0

If you are using options.js the revelvant line of code looks something like this (shown with the replace code that worked for me):

 

 

    jQuery('#price-preview').html(Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}").replace(".00", ""));

 

 

usually in San Francisco...
0 Likes
Highlighted
Shopify Partner
39 0 0

Thanks for pointing this out, saved me alot of time!

And thanks to pointing out that detail wayne, made it even easier to get it done!

CoverMe.dk - Design Laptop Covers
0 Likes
New Member
2 0 0

Dear all, 

I have tried to follow your instructions closely, but still did not succeed. Would you be so kind as to help me? My skills in this are are very limited. 

This is the piece of code I have in product.liquid (I added myself the | remove: '.00'):

{% if product.available %}

    <input class="button right" type="submit" id="add" value="{{ settings.product_page_buy_button_text }}" />

    <span id="product_price">

    <span id="price-field">{{ product.price | money | remove: '.00' }}</span>

{% if product.compare_at_price_max > product.price %}<span class="price_compare"><del>{{ product.compare_at_price_max | money }}</del> &nbsp; </span>{% endif %}

   </span>

{% else %}

<span class="sold_out">Sold Out</span>

{% endif %}

However I found no effect on the price of the website (in any of the pages) which BTW is www.bucarelli.com

I also edited product_variant_javascript.liquid to look like this:

// <![CDATA[  

  var selectCallback = function(variant, selector) {

    if (variant && variant.available == true) {

      // selected a valid variant

      jQuery('#purchase').removeClass('disabled').removeAttr('disabled'); // remove unavailable class from add-to-cart button, and re-enable button

      jQuery('.current-price').html(Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}").replace(".00", ""));  // update price field

    } else {

      // variant doesn't exist

      jQuery('#purchase').addClass('disabled').attr('disabled', 'disabled');      // set add-to-cart button to unavailable class and disable button

      sold_out = {% assign value = "sold-out" %}"{% include 'translations' with value %}";

      unavailable = {% assign value = "unavailable" %}"{% include 'translations' with value %}";

  {% assign value = null %}

  var message = variant ? sold_out : unavailable;

  $(".current-price").html(Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}").replace(".00", ""));

    }

  };

 

Where it says    $(".current-price").html(Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}").replace(".00", ""));

It used to say $(".current-price").text(message) or .message(text) cannot remember. I am not working with product variants, every product has its own product page in the admin section.

However, I have not noticed any change... could you please help? I am getting a bit desperate :)

All the best, 

Luis

0 Likes
New Member
2 0 0

How would you multiply a price. I see in your example that you divided

0 Likes
New Member
1 0 0

where do I put this? 

{{ product.price | money_without_currency | remove: '.00' }}
 

I want to remove it from everywhere

0 Likes
Tourist
36 0 1

My question is similar to ones above... I want to take the product price, remove decimals, and divide it by 25 and show it in $ currency.  Ex. 

Product Price: $1000

Show: $40       (given $1000 divided by 25). 

I have this so far but it's not working:
 

<h4><p class="price">{{ product.price | money | remove: '.00'|divided_by: 25 }}</p></h4>

Here is a link to show it just says "0"

http://www.sugarloft.ca/collections/seating/products/jenegg-chair

Help?

0 Likes
Shopify Expert
189 0 15

Brody;

Money filter must be at the end, you will make the calculation using numbers only then convert it to money {{product.price}} is itself a number only

 

 

Pasilobus, Inc - Shopify Experts - Contact us at support@pasilobus.com
0 Likes
New Member
1 0 1

Solution that will change price formatting across all pages.

 

Click into Settings and stay on the General tab.

Scroll down to Standards & formats area.

Click change formatting.

It will look like this: 
<span class=money>${{amount}} USD</span>

if you want to remove decimal points add {{amount_no_decimals}}

you can remove USD it's only html text.

Output will read $__

1 Like