PageSourceSearch

https://shop.zoo.dk/assets/standard-shop/scripts/giftCertificate-556fbe683540f5e0af854c11dde6d1df.js

js zoo.dk collected 2026-09-24 20:53:14 UTC 2,108 bytes, 100 lines download raw bytes

1/* global checkout, common, messages, miniCart, modal */
2/* exported giftCertificate */
3const giftCertificate = {
4
5	/**
6	 * Add gift certificate code.
7	 *
8	 * @param {string} code
9	 * @param {Function} callback
10	 */
11	add: function(code, callback) {
12		common.ajaxLoader({
13			url: '/cart/module',
14			data: {
15				module: 'gift_certificate',
16				gift_certificate: {
17					add_code: {
18						0: code
19					}
20				}
21			},
22			success: function(response) {
23				const data = response.data[0] === undefined ? response.data : response.data[0];
24				if (data.success) {
25					if (callback === undefined) {
26						messages.addSuccess(data.message, false);
27					}
28					else {
29						callback(data.message);
30					}
31				}
32				else {
33					modal.createAlert({
34						body: data.message,
35						type: 'danger'
36					});
37				}
38			}
39		});
40	},
41
42	/**
43	 * Add gift certificate code, but stay on the page replacing the button with feedback.
44	 *
45	 * @param {string} code
46	 * @param {HTMLElement} element
47	 */
48	addAndStay: function(code, element) {
49		this.add(code, function(message) {
50			$(element).replaceWith(message);
51			miniCart.updateIcon();
52		});
53	},
54
55	/**
56	 * Add gift certificate code and redirect to redirectTo (likely cart).
57	 *
58	 * @param {string} code
59	 * @param {string} redirectTo
60	 */
61	addAndRedirect: function(code, redirectTo) {
62		this.add(code, function() {
63			window.location.href = redirectTo;
64		});
65	},
66
67	/**
68	 * Remove the specified gift certificate from the cart.
69	 *
70	 * @param {number} giftCertificateId
71	 */
72	remove: function(giftCertificateId) {
73		common.ajaxLoader({
74			url: '/cart/module',
75			method: 'POST',
76			data: {
77				module: 'gift_certificate',
78				gift_certificate: {
79					delete_code: {
80						0: giftCertificateId
81					}
82				}
83			},
84			success: function(response) {
85				if (response.data[0].success === true) {
86					// Code has been deleted
87					messages.addSuccess(response.data[0].message, false);
88					setTimeout(function() {
89						checkout.updateCart(true);
90					}, 300);
91				}
92				else {
93					// Invalid gift certificate code
94					modal.createAlert('Unknown gift certificate');
95				}
96			}
97		});
98	}
99
100};

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.