Stiletto price formatting

Topic summary

Issue: Currency formatting in the Stiletto theme shows prices ≥ 1,000 kr as “1,000 kr,” which Google interprets as 1 kr. Changing Shopify’s currency format to {{ amount_no_decimals_with_space_separator }} fixes the display, but the price disappears when switching product variants.

Update: The user edited theme.js to customize formatMoney, using the Swedish locale (sv-SE) to insert a space as the thousands separator and appending “ kr.” They integrated this with onOptionChange and updatePrices so variant prices render.

Current state: The base product price formats correctly, and variant prices now appear, but variant updates still output with an incorrect thousands separator or without the intended formatting. The behavior suggests the update is pulling a format that ignores the custom formatting.

Key elements: The provided JavaScript code and formatting logic are central to understanding the issue.

Outcome: Partial fix achieved; consistent formatting across variant changes remains unresolved. Assistance is requested to ensure space-separated thousands are applied everywhere and to avoid Google misinterpreting prices.

Summarized with AI on December 22. AI used: gpt-5.

Hello,

i have an problem with the currency formatting with the stiletto theme, the problem is that all products that cost more than 1000 kr is formated as 1,000 kr and google interpreters this as 1 kr. I have tried to change the formatting under settings->general then currency formatting to {{ amount_no_decimals_with_space_separator }} but then the price dissapears when I switch between variants. Please help me.

Okay, so I’ve solved part of the problem. In Theme.JS, I’ve reformatted the code so that I have the following code in the JavaScript. This ensures that the price formatting is correct for the product. Now the price also appears on the other variants, but with a thousand separator, as it updates the file without the formatting. Please help me.

const moneyFormat = ‘${{amount_no_decimals}}’;

function formatMoney$1(cents, format) {
if (typeof cents === ‘string’) {
cents = cents.replace(/\s/g, ‘’);
}
let value = ‘’;
const placeholderRegex = /{{\s*(\w+)\s*}}/;
const formatString = format || moneyFormat;

function formatAmountNoDecimals(cents) {
let amount = Math.floor(cents / 100);
return amount.toLocaleString(‘sv-SE’); // Use Swedish locale to add the space as a thousand separator
}

function formatWithDelimiters(
number,
precision = 2,
thousands = ’ ',
decimal = ‘.’
) {
if (isNaN(number) || number == null) {
return ‘0’;
}

number = (number / 100.0).toFixed(precision);
const parts = number.split(‘.’);
const dollarsAmount = parts[0].replace(
/(\d)(?=(\d{3})+(?!\d))/g,
$1${thousands}
);
const centsAmount = parts[1] ? decimal + parts[1] : ‘’;

return dollarsAmount + centsAmount;
}

switch (formatString.match(placeholderRegex)[1]) {
case ‘amount’:
value = formatWithDelimiters(cents, 2);
break;
case ‘amount_no_decimals’:
value = formatAmountNoDecimals(cents); // Apply the Swedish locale formatting
break;
case ‘amount_with_comma_separator’:
value = formatWithDelimiters(cents, 2, ’ ', ‘,’);
break;
case ‘amount_no_decimals_with_comma_separator’:
value = formatWithDelimiters(cents, 0, ’ ', ‘,’);
break;
}

return formatString.replace(placeholderRegex, value) + ’ kr’; // Ensure ’ kr’ is always added
}

var formatMoney = (val => formatMoney$1(val, window.theme.moneyFormat || “${{amount_no_decimals}}”));

onOptionChange(_ref2) {
let {
dataset: {
variant
},
srcElement
} = _ref2;

const optionParentWrapper = srcElement.closest(selectors$G.productOption);
const optionLabel = n$2(selectors$G.optionLabelValue, optionParentWrapper);
if (optionLabel) {
optionLabel.textContent = srcElement.value;
}

const buyButtonEls = t$2(selectors$G.addToCart, this.container);
const priceWrapper = n$2(selectors$G.priceWrapper, this.container);
priceWrapper && l(priceWrapper, “hide”, !variant);

// Ensure the price is formatted correctly
const defaultProductTemplate = this.isFullProduct === “true” ? true : false;
updatePrices(this.container, variant, defaultProductTemplate);