fix: totals

This commit is contained in:
Nikita Kiselev
2025-07-23 19:39:50 +03:00
parent f5cac7d566
commit eb1f1dc9c1
3 changed files with 59 additions and 36 deletions

View File

@@ -224,36 +224,33 @@ class Controllerextensiontgshophandle extends Controller
'total' => &$total 'total' => &$total
); );
// Display prices $sort_order = array();
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$sort_order = array();
$results = $this->model_setting_extension->getExtensions('total'); $results = $this->model_setting_extension->getExtensions('total');
foreach ($results as $key => $value) { foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
if ($this->config->get('total_' . $result['code'] . '_status')) {
$this->load->model('extension/total/' . $result['code']);
// We have to put the totals in an array so that they pass by reference.
$this->{'model_extension_total_' . $result['code']}->getTotal($total_data);
}
}
$sort_order = array();
foreach ($totals as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $totals);
} }
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
if ($this->config->get('total_' . $result['code'] . '_status')) {
$this->load->model('extension/total/' . $result['code']);
// We have to put the totals in an array so that they pass by reference.
$this->{'model_extension_total_' . $result['code']}->getTotal($total_data);
}
}
$sort_order = array();
foreach ($totals as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $totals);
$data['totals'] = array(); $data['totals'] = array();
foreach ($totals as $total) { foreach ($totals as $total) {
@@ -264,7 +261,6 @@ class Controllerextensiontgshophandle extends Controller
} }
$data['total_products_count'] = $this->cart->countProducts(); $data['total_products_count'] = $this->cart->countProducts();
$data['total'] = $this->cart->getTotal();
} else { } else {
$data['text_error'] = $this->language->get('text_empty'); $data['text_error'] = $this->language->get('text_empty');
$data['totals'] = []; $data['totals'] = [];

View File

@@ -10,6 +10,7 @@
:navigation="true" :navigation="true"
:modules="modules" :modules="modules"
class="mySwiper w-full min-h-[200px]" class="mySwiper w-full min-h-[200px]"
@touchMove="onTouchMove"
> >
<swiper-slide v-for="image in images"> <swiper-slide v-for="image in images">
<img <img
@@ -34,6 +35,7 @@ import 'swiper/css/pagination';
import {Pagination} from 'swiper/modules'; import {Pagination} from 'swiper/modules';
export default { export default {
components: { components: {
Swiper, Swiper,
@@ -48,12 +50,37 @@ export default {
}, },
setup() { setup() {
const throttle = (func, delay) => {
let lastCall = 0;
return (...args) => {
const now = Date.now();
if (now - lastCall >= delay) {
lastCall = now;
func(...args);
}
};
};
const hapticTick = throttle(() => {
const haptic = window?.Telegram?.WebApp?.HapticFeedback;
if (haptic?.selectionChanged) {
haptic.selectionChanged();
} else if (haptic?.impactOccurred) {
haptic.impactOccurred('light');
}
}, 100);
const onTouchMove = () => {
hapticTick();
};
return { return {
pagination: { pagination: {
clickable: true, clickable: true,
dynamicBullets: true, dynamicBullets: true,
}, },
modules: [Pagination], modules: [Pagination],
onTouchMove, // ← вот это добавь
}; };
}, },
}; };

View File

@@ -77,16 +77,16 @@
</div> </div>
</div> </div>
<div class="fixed bottom-0 left-0 w-full px-4 pb-10 pt-4 bg-base-200 z-50 border-t-1 border-t-base-300"> <div class="fixed px-4 pb-10 pt-4 bottom-0 left-0 w-full bg-base-200 z-50 flex justify-between items-center gap-2 border-t-1 border-t-base-300">
<!-- <div>--> <div>
<!-- <div v-if="lastTotal">--> <div v-if="lastTotal">
<!-- <span class="text-xs text-base-content mr-2">{{ lastTotal.title }}:</span><br>--> <span class="text-xs text-base-content mr-2">{{ lastTotal.title }}:</span><br>
<!-- <span v-if="cart.isLoading" class="loading loading-spinner loading-xs"></span>--> <span v-if="cart.isLoading" class="loading loading-spinner loading-xs"></span>
<!-- <span v-else class="text-accent font-bold">{{ lastTotal.text }}</span>--> <span v-else class="text-accent font-bold">{{ lastTotal.text }}</span>
<!-- </div>--> </div>
<!-- </div>--> </div>
<button class="btn btn-primary w-full" :disabled="cart.canCheckout === false">Перейти к оформлению</button> <button class="btn btn-primary" :disabled="cart.canCheckout === false">Перейти к оформлению</button>
</div> </div>
</div> </div>