Fix | харкод рубля в обновлении цены в корзине

dev_10_refactoring
parent d1e33b17d2
commit a50c908cf1
  1. 8
      wp-content/themes/cosmopet/modules/shop/components/cart/assets/js/cart.js

@ -25,9 +25,13 @@ $(document).on('change', '.counter__input', function () {
const unitPrice = currentTotal / oldQuantity;
const newTotal = unitPrice * quantity;
// Обновить цену
// Получаем текущий символ валюты из разметки
const currencySymbol = $priceElement.find('.woocommerce-Price-currencySymbol').text().trim();
// Формируем новую цену с тем же символом
$priceElement.find('bdi').html(
newTotal.toLocaleString('ru-RU', { minimumFractionDigits: 0 }) + '&nbsp;<span class="woocommerce-Price-currencySymbol">₽</span>'
newTotal.toLocaleString('ru-RU', { minimumFractionDigits: 0 }) +
'&nbsp;<span class="woocommerce-Price-currencySymbol">' + currencySymbol + '</span>'
);
// Обновить значение по умолчанию (чтобы расчёт unitPrice был корректен в следующий раз)

Loading…
Cancel
Save