PageSourceSearch

https://mozaik-knjiga.hr/wp-content/themes/am2/resources/js/routes/blocks/cart.js

js mozaik-knjiga.hr collected 2026-10-02 07:58:12 UTC 2,008 bytes, 44 lines download raw bytes

1export default {
2    init: () => {
3        // Listen for a custom event, or any other action
4        jQuery(document).on('click', '#move-coupon-button', function() {
5            // Trigger AJAX request to move the coupon
6            jQuery.ajax({
7                url: am2.AJAX,  // Your AJAX URL (replace with actual)
8                type: 'POST',
9                data: {
10                    action: 'move_coupon_field_to_left_cart'  // The custom action that we defined in PHP
11                },
12                success: function(response) {
13                    if (response.success) {
14                        // If the coupon is successfully moved, we can update the UI
15                        alert(response.data.message); // Display a success message
16                        // Now move the coupon HTML element to a new location (example)
17                        jQuery('#coupon-field').prependTo('#left-side-of-cart');
18                    } else {
19                        alert('Došlo je do pogreške pri premještanju kupona!');
20                    }
21                },
22                error: function(xhr, status, error) {
23                    console.error('AJAX error: ' + error);
24                    alert('Došlo je do pogreške. Pokušajte ponovo.');
25                }
26            });
27        });
28
29        // Optionally, you can also update cart totals after the coupon has been moved.
30        jQuery(document.body).on('updated_cart_totals', function() {
31            console.log('Cart updated');
32            jQuery.get(am2.AJAX, { action: 'get_cart_count' }, function(response) {
33                console.log(response); // Provjerite što vraća server
34                if (response && response.cart_count !== undefined) {
35                    jQuery('.cart-count').html(response.cart_count); // Update the cart count value
36                }
37            });
38        });
39    },
40    complete: () => {
41        // Additional functionality after the cart is updated can go here
42    },
43    extends: []
44};

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.