PageSourceSearch

https://ambachtinbeeldfestival.nl/wp-content/plugins/voordemensen/js/vdm_session.js?ver=2.1.3

js ambachtinbeeldfestival.nl collected 2026-10-02 13:22:44 UTC 4,740 bytes, 121 lines download raw bytes

1function vdmOrderWithSession(eventId, buttonId) {
2    var vdmRedirect = (typeof vdm_basketcounter_data !== 'undefined' && vdm_basketcounter_data.redirect_url) ? vdm_basketcounter_data.redirect_url : '';
3    var sessionId = getCookie('voordemensen_session_id');
4    if (sessionId) {
5        vdm_order(eventId, sessionId, '', vdmRedirect, '');
6    } else {
7
8        // Make an AJAX request to fetch the nonce first
9        jQuery.ajax({
10            url: ajaxurl,
11            method: 'POST',
12            data: {
13                action: 'voordemensen_generate_nonce',
14                security: vdm_basketcounter_data.nonce
15            },
16            success: function(response) {
17                if (response.success && response.data.nonce) {
18
19                    // Now make an AJAX request to fetch the session ID
20                    jQuery.ajax({
21                        url: ajaxurl,
22                        method: 'POST',
23                        data: {
24                            action: 'voordemensen_fetch_session_id',
25                            security: response.data.nonce
26                        },
27                        success: function(response) {
28                            if (response.success && response.data.session_id) {
29                                vdm_order(eventId, response.data.session_id, '', vdmRedirect, '');
30                            } else {
31                                console.error('Failed to fetch session ID:', response.data);
32                            }
33                        },
34                        error: function(error) {
35                            console.error('Error fetching session ID:', error);
36                        }
37                    });
38                } else {
39                    console.error('Failed to generate nonce:', response.data);
40                }
41            },
42            error: function(error) {
43                console.error('Error generating nonce:', error);
44            }
45        });
46    }
47}
48
49// Utility function to get cookie value by name
50function getCookie(name) {
51    const value = `; ${document.cookie}`;
52    const parts = value.split(`; ${name}=`);
53    if (parts.length === 2) return parts.pop().split(';').shift();
54}
55
56jQuery(document).ready(function($) {
57    // Fetch the session ID and update the basket counter
58    function fetchSessionIdAndUpdateBasket() {
59        // Use the cart-session cookie if we already have one.
60        var sessionId = getCookie('voordemensen_session_id');
61        if (sessionId) {
62            updateBasketCounter(sessionId);
63        } else {
64            // Make an AJAX request to fetch the session ID
65            $.ajax({
66                url: ajaxurl,
67                method: 'POST',
68                data: {
69                    action: 'voordemensen_fetch_session_id',
70                    security: vdm_basketcounter_data.nonce
71
72                },
73                success: function(response) {
74                    if (response.success && response.data.session_id) {
75                        const sessionId = response.data.session_id;
76                        updateBasketCounter(sessionId);
77                    } else {
78                        console.error('Failed to fetch session ID:', response.data);
79                    }
80                },
81                error: function(error) {
82                    console.error('Error fetching session ID:', error);
83                }
84            });
85        }
86    }
87
88    // Update the basket counter
89    function updateBasketCounter(sessionId) {
90        const clientShortname = vdm_basketcounter_data.client_shortname;
91        const domainName = vdm_basketcounter_data.domain_name;
92        
93        $.ajax({
94            url: `https://${domainName}/api/${clientShortname}/cart/${sessionId}`,
95            method: 'GET',
96            success: function(response) {
97                let content;
98                if (Array.isArray(response) || typeof response === 'object') {
99                    content = Object.keys(response).length - 1;  // Count items in the cart
100                } else {
101                    content = 'n/a';
102                }
103                $('.vdm_basketcounter').text(content);
104            },
105            error: function(error) {
106                console.error('Error fetching basket count:', error);
107                $('.vdm_basketcounter').text('n/a');
108            }
109        });
110    }
111
112    // Utility function to get cookie value by name
113    function getCookie(name) {
114        const value = `; ${document.cookie}`;
115        const parts = value.split(`; ${name}=`);
116        if (parts.length === 2) return parts.pop().split(';').shift();
117    }
118
119    // Fetch the session ID and update the basket counter on page load
120    fetchSessionIdAndUpdateBasket();
121});

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.