PageSourceSearch

https://www.naamanp.co.il/pub/static/version1783840592/frontend/Id…/js/view/configure/product-customer-data.js

js naamanp.co.il collected 2026-09-26 11:15:07 UTC 1,769 bytes, 65 lines download raw bytes

1require([
2    'jquery',
3    'Magento_Customer/js/customer-data',
4    'underscore',
5    'domReady!'
6], function ($, customerData, _) {
7    'use strict';
8
9    var selectors = {
10        qtySelector: '#product_addtocart_form [name="qty"]',
11        productIdSelector: '#product_addtocart_form [name="product"]',
12        itemIdSelector: '#product_addtocart_form [name="item"]'
13    },
14    cartData = customerData.get('cart'),
15    productId = $(selectors.productIdSelector).val(),
16    itemId = $(selectors.itemIdSelector).val(),
17    productQty,
18    productQtyInput,
19
20    /**
21    * Updates product's qty input value according to actual data
22    */
23    updateQty = function () {
24
25        if (productQty || productQty === 0) {
26            productQtyInput = productQtyInput || $(selectors.qtySelector);
27
28            if (productQtyInput && productQty.toString() !== productQtyInput.val()) {
29                productQtyInput.val(productQty);
30            }
31        }
32    },
33
34    /**
35    * Sets productQty according to cart data from customer-data
36    *
37    * @param {Object} data - cart data from customer-data
38    */
39    setProductQty = function (data) {
40        var product;
41
42        if (!(data && data.items && data.items.length && productId)) {
43            return;
44        }
45        product = _.find(data.items, function (item) {
46            if (item['item_id'] === itemId) {
47                return item['product_id'] === productId ||
48                    item['item_id'] === productId;
49            }
50        });
51
52        if (!product) {
53            return;
54        }
55        productQty = product.qty;
56    };
57
58    cartData.subscribe(function (updateCartData) {
59        setProductQty(updateCartData);
60        updateQty();
61    });
62
63    setProductQty(cartData());
64    updateQty();
65});

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.