PageSourceSearch

https://optivita.us/wp-content/themes/mrbara-child/assets/js/app.js

js optivita.us collected 2026-10-09 21:27:42 UTC 1,067 bytes, 22 lines download raw bytes

1jQuery(function($) {
2    let cartOpened = false;
3
4    // Зберігаємо ID продукту, який був натиснутий
5    let lastClickedProductId = null;
6
7    // Слідкуємо за кліком по кнопці "додати в кошик"
8    $(document.body).on('click', '.ajax_add_to_cart', function(e) {
9        const $btn = $(this);
10        lastClickedProductId = $btn.data('product_id');
11        cartOpened = false; // скидаємо флаг при кожному новому кліку
12    });
13
14    // Слухаємо подію, яку WooCommerce викликає після успішного додавання
15    $(document.body).on('added_to_cart', function(event, fragments, cart_hash, $button) {
16        // Перевіряємо, чи це кнопка того самого продукту, який ми натискали
17        if (!cartOpened && $button && $button.data('product_id') === lastClickedProductId) {
18            $('body').addClass('display-cart');
19            cartOpened = true;
20        }
21    });
22});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.