flowrix 1.0.1-beta.147 → 1.0.1-beta.148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +5 -0
  3. package/dist/runtime/components/SampleProductCard.d.vue.ts +13 -0
  4. package/dist/runtime/components/SampleProductCard.vue +362 -0
  5. package/dist/runtime/components/SampleProductCard.vue.d.ts +13 -0
  6. package/dist/runtime/components/WishList/dropdown.d.vue.ts +9 -0
  7. package/dist/runtime/components/WishList/dropdown.vue +417 -0
  8. package/dist/runtime/components/WishList/dropdown.vue.d.ts +9 -0
  9. package/dist/runtime/components/WishList/modal.d.vue.ts +13 -0
  10. package/dist/runtime/components/WishList/modal.vue +229 -0
  11. package/dist/runtime/components/WishList/modal.vue.d.ts +13 -0
  12. package/dist/runtime/components/product/AddToCart.d.vue.ts +15 -0
  13. package/dist/runtime/components/product/AddToCart.vue +176 -0
  14. package/dist/runtime/components/product/AddToCart.vue.d.ts +15 -0
  15. package/dist/runtime/components/product/AddtoCartSample.d.vue.ts +6 -0
  16. package/dist/runtime/components/product/AddtoCartSample.vue +110 -0
  17. package/dist/runtime/components/product/AddtoCartSample.vue.d.ts +6 -0
  18. package/dist/runtime/components/product/Badges.d.vue.ts +13 -0
  19. package/dist/runtime/components/product/Badges.vue +84 -0
  20. package/dist/runtime/components/product/Badges.vue.d.ts +13 -0
  21. package/dist/runtime/components/product/Description.d.vue.ts +9 -0
  22. package/dist/runtime/components/product/Description.vue +96 -0
  23. package/dist/runtime/components/product/Description.vue.d.ts +9 -0
  24. package/dist/runtime/components/product/Dynamic.d.vue.ts +9 -0
  25. package/dist/runtime/components/product/Dynamic.vue +136 -0
  26. package/dist/runtime/components/product/Dynamic.vue.d.ts +9 -0
  27. package/dist/runtime/components/product/Gallery.d.vue.ts +11 -0
  28. package/dist/runtime/components/product/Gallery.vue +133 -0
  29. package/dist/runtime/components/product/Gallery.vue.d.ts +11 -0
  30. package/dist/runtime/components/product/PopUpCart.d.vue.ts +11 -0
  31. package/dist/runtime/components/product/PopUpCart.vue +155 -0
  32. package/dist/runtime/components/product/PopUpCart.vue.d.ts +11 -0
  33. package/dist/runtime/components/product/ProductInfo.d.vue.ts +7 -0
  34. package/dist/runtime/components/product/ProductInfo.vue +105 -0
  35. package/dist/runtime/components/product/ProductInfo.vue.d.ts +7 -0
  36. package/dist/runtime/components/product/RequiredPopUp.d.vue.ts +9 -0
  37. package/dist/runtime/components/product/RequiredPopUp.vue +57 -0
  38. package/dist/runtime/components/product/RequiredPopUp.vue.d.ts +9 -0
  39. package/dist/runtime/components/product/bundleProduct/Bundle.d.vue.ts +13 -0
  40. package/dist/runtime/components/product/bundleProduct/Bundle.vue +35 -0
  41. package/dist/runtime/components/product/bundleProduct/Bundle.vue.d.ts +13 -0
  42. package/dist/runtime/components/product/bundleProduct/index.d.vue.ts +8 -0
  43. package/dist/runtime/components/product/bundleProduct/index.vue +32 -0
  44. package/dist/runtime/components/product/bundleProduct/index.vue.d.ts +8 -0
  45. package/dist/runtime/components/product/customProduct/AddtoCartSample.d.vue.ts +6 -0
  46. package/dist/runtime/components/product/customProduct/AddtoCartSample.vue +101 -0
  47. package/dist/runtime/components/product/customProduct/AddtoCartSample.vue.d.ts +6 -0
  48. package/dist/runtime/components/product/customProduct/Attributes.d.vue.ts +9 -0
  49. package/dist/runtime/components/product/customProduct/Attributes.vue +12 -0
  50. package/dist/runtime/components/product/customProduct/Attributes.vue.d.ts +9 -0
  51. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/drop-down.d.vue.ts +13 -0
  52. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/drop-down.vue +11 -0
  53. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/drop-down.vue.d.ts +13 -0
  54. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/multi-collection.d.vue.ts +3 -0
  55. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/multi-collection.vue +253 -0
  56. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/multi-collection.vue.d.ts +3 -0
  57. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/multi-colors.d.vue.ts +3 -0
  58. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/multi-colors.vue +253 -0
  59. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/multi-colors.vue.d.ts +3 -0
  60. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/multi-values.d.vue.ts +3 -0
  61. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/multi-values.vue +214 -0
  62. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/multi-values.vue.d.ts +3 -0
  63. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/style.d.vue.ts +13 -0
  64. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/style.vue +9 -0
  65. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/style.vue.d.ts +13 -0
  66. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/swatch.d.vue.ts +13 -0
  67. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/swatch.vue +9 -0
  68. package/dist/runtime/components/product/customProduct/AttributesComponents/AttributeType/swatch.vue.d.ts +13 -0
  69. package/dist/runtime/components/product/customProduct/AttributesComponents/PopupContent/Popup.d.vue.ts +9 -0
  70. package/dist/runtime/components/product/customProduct/AttributesComponents/PopupContent/Popup.vue +133 -0
  71. package/dist/runtime/components/product/customProduct/AttributesComponents/PopupContent/Popup.vue.d.ts +9 -0
  72. package/dist/runtime/components/product/customProduct/AttributesComponents/SingleAttribute.d.vue.ts +11 -0
  73. package/dist/runtime/components/product/customProduct/AttributesComponents/SingleAttribute.vue +35 -0
  74. package/dist/runtime/components/product/customProduct/AttributesComponents/SingleAttribute.vue.d.ts +11 -0
  75. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/SingleSlide.d.vue.ts +13 -0
  76. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/SingleSlide.vue +134 -0
  77. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/SingleSlide.vue.d.ts +13 -0
  78. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/SingleSlidemagnifier.d.vue.ts +15 -0
  79. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/SingleSlidemagnifier.vue +138 -0
  80. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/SingleSlidemagnifier.vue.d.ts +15 -0
  81. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/button.d.vue.ts +11 -0
  82. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/button.vue +149 -0
  83. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/button.vue.d.ts +11 -0
  84. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/dropdown.d.vue.ts +11 -0
  85. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/dropdown.vue +82 -0
  86. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/dropdown.vue.d.ts +11 -0
  87. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/dropdownWithIcon.d.vue.ts +11 -0
  88. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/dropdownWithIcon.vue +108 -0
  89. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/dropdownWithIcon.vue.d.ts +11 -0
  90. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/height.d.vue.ts +11 -0
  91. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/height.vue +104 -0
  92. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/height.vue.d.ts +11 -0
  93. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/imageBox.d.vue.ts +11 -0
  94. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/imageBox.vue +87 -0
  95. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/imageBox.vue.d.ts +11 -0
  96. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/imageBoxWithMagnifier.d.vue.ts +11 -0
  97. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/imageBoxWithMagnifier.vue +219 -0
  98. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/imageBoxWithMagnifier.vue.d.ts +11 -0
  99. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/message.d.vue.ts +11 -0
  100. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/message.vue +36 -0
  101. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/message.vue.d.ts +11 -0
  102. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/number.d.vue.ts +11 -0
  103. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/number.vue +45 -0
  104. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/number.vue.d.ts +11 -0
  105. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/orderSample/button.d.vue.ts +13 -0
  106. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/orderSample/button.vue +48 -0
  107. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/orderSample/button.vue.d.ts +13 -0
  108. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/radio.d.vue.ts +11 -0
  109. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/radio.vue +154 -0
  110. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/radio.vue.d.ts +11 -0
  111. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/slider.d.vue.ts +11 -0
  112. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/slider.vue +111 -0
  113. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/slider.vue.d.ts +11 -0
  114. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/sliderWithMagnifier.d.vue.ts +11 -0
  115. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/sliderWithMagnifier.vue +269 -0
  116. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/sliderWithMagnifier.vue.d.ts +11 -0
  117. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/subheight.d.vue.ts +11 -0
  118. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/subheight.vue +63 -0
  119. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/subheight.vue.d.ts +11 -0
  120. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/subwidth.d.vue.ts +11 -0
  121. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/subwidth.vue +63 -0
  122. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/subwidth.vue.d.ts +11 -0
  123. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/swatch.d.vue.ts +11 -0
  124. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/swatch.vue +220 -0
  125. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/swatch.vue.d.ts +11 -0
  126. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/text.d.vue.ts +11 -0
  127. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/text.vue +47 -0
  128. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/text.vue.d.ts +11 -0
  129. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/width.d.vue.ts +11 -0
  130. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/width.vue +91 -0
  131. package/dist/runtime/components/product/customProduct/AttributesComponents/Styles/width.vue.d.ts +11 -0
  132. package/dist/runtime/components/product/customProduct/ConfirmPopup.d.vue.ts +9 -0
  133. package/dist/runtime/components/product/customProduct/ConfirmPopup.vue +25 -0
  134. package/dist/runtime/components/product/customProduct/ConfirmPopup.vue.d.ts +9 -0
  135. package/dist/runtime/components/product/customProduct/RequiredPopUp.d.vue.ts +9 -0
  136. package/dist/runtime/components/product/customProduct/RequiredPopUp.vue +49 -0
  137. package/dist/runtime/components/product/customProduct/RequiredPopUp.vue.d.ts +9 -0
  138. package/dist/runtime/components/product/customProduct/Reviews.d.vue.ts +7 -0
  139. package/dist/runtime/components/product/customProduct/Reviews.vue +25 -0
  140. package/dist/runtime/components/product/customProduct/Reviews.vue.d.ts +7 -0
  141. package/dist/runtime/components/product/customProduct/SingleStep.d.vue.ts +11 -0
  142. package/dist/runtime/components/product/customProduct/SingleStep.vue +11 -0
  143. package/dist/runtime/components/product/customProduct/SingleStep.vue.d.ts +11 -0
  144. package/dist/runtime/components/product/customProduct/Steps.d.vue.ts +9 -0
  145. package/dist/runtime/components/product/customProduct/Steps.vue +221 -0
  146. package/dist/runtime/components/product/customProduct/Steps.vue.d.ts +9 -0
  147. package/dist/runtime/components/product/customProduct/index.d.vue.ts +9 -0
  148. package/dist/runtime/components/product/customProduct/index.vue +272 -0
  149. package/dist/runtime/components/product/customProduct/index.vue.d.ts +9 -0
  150. package/dist/runtime/components/product/index.d.vue.ts +8 -0
  151. package/dist/runtime/components/product/index.vue +90 -0
  152. package/dist/runtime/components/product/index.vue.d.ts +8 -0
  153. package/dist/runtime/components/product/sampleProduct/ProductVariation.d.vue.ts +11 -0
  154. package/dist/runtime/components/product/sampleProduct/ProductVariation.vue +61 -0
  155. package/dist/runtime/components/product/sampleProduct/ProductVariation.vue.d.ts +11 -0
  156. package/dist/runtime/components/product/sampleProduct/SampleDetails.d.vue.ts +7 -0
  157. package/dist/runtime/components/product/sampleProduct/SampleDetails.vue +74 -0
  158. package/dist/runtime/components/product/sampleProduct/SampleDetails.vue.d.ts +7 -0
  159. package/dist/runtime/components/product/sampleProduct/SampleFeatures.d.vue.ts +9 -0
  160. package/dist/runtime/components/product/sampleProduct/SampleFeatures.vue +63 -0
  161. package/dist/runtime/components/product/sampleProduct/SampleFeatures.vue.d.ts +9 -0
  162. package/dist/runtime/components/product/sampleProduct/index.d.vue.ts +8 -0
  163. package/dist/runtime/components/product/sampleProduct/index.vue +64 -0
  164. package/dist/runtime/components/product/sampleProduct/index.vue.d.ts +8 -0
  165. package/dist/runtime/components/product/simpleProduct/ProductVariation.d.vue.ts +11 -0
  166. package/dist/runtime/components/product/simpleProduct/ProductVariation.vue +61 -0
  167. package/dist/runtime/components/product/simpleProduct/ProductVariation.vue.d.ts +11 -0
  168. package/dist/runtime/components/product/simpleProduct/index.d.vue.ts +8 -0
  169. package/dist/runtime/components/product/simpleProduct/index.vue +34 -0
  170. package/dist/runtime/components/product/simpleProduct/index.vue.d.ts +8 -0
  171. package/dist/runtime/composables/Product/CustomProductDynamic/useAttributeTypeDynamic.d.ts +3 -0
  172. package/dist/runtime/composables/Product/CustomProductDynamic/useAttributeTypeDynamic.js +20 -0
  173. package/dist/runtime/composables/Product/CustomProductDynamic/useAttributesDynamic.d.ts +70 -0
  174. package/dist/runtime/composables/Product/CustomProductDynamic/useAttributesDynamic.js +63 -0
  175. package/dist/runtime/composables/Product/CustomProductDynamic/useCustomProductDynamic.d.ts +74 -0
  176. package/dist/runtime/composables/Product/CustomProductDynamic/useCustomProductDynamic.js +107 -0
  177. package/dist/runtime/composables/Product/CustomProductDynamic/useCustomeScriptDynamic.d.ts +159 -0
  178. package/dist/runtime/composables/Product/CustomProductDynamic/useCustomeScriptDynamic.js +2079 -0
  179. package/dist/runtime/composables/Product/CustomProductDynamic/useSingleAttributeDynamic.d.ts +4 -0
  180. package/dist/runtime/composables/Product/CustomProductDynamic/useSingleAttributeDynamic.js +27 -0
  181. package/dist/runtime/composables/Product/CustomProductDynamic/useSingleStepDynamic.d.ts +68 -0
  182. package/dist/runtime/composables/Product/CustomProductDynamic/useSingleStepDynamic.js +21 -0
  183. package/dist/runtime/composables/Product/CustomProductDynamic/useSingleValueDynamic.d.ts +67 -0
  184. package/dist/runtime/composables/Product/CustomProductDynamic/useSingleValueDynamic.js +15 -0
  185. package/dist/runtime/composables/Product/CustomProductDynamic/useStepsDynamic.d.ts +88 -0
  186. package/dist/runtime/composables/Product/CustomProductDynamic/useStepsDynamic.js +72 -0
  187. package/dist/runtime/composables/index.d.ts +8 -0
  188. package/dist/runtime/composables/index.js +8 -0
  189. package/dist/runtime/pages/flowrix-default.vue +15 -6
  190. package/dist/runtime/plugins/bootstrap.client.d.ts +2 -0
  191. package/dist/runtime/plugins/bootstrap.client.js +9 -0
  192. package/dist/runtime/server/api/cart/related.js +15 -2
  193. package/package.json +1 -1
@@ -0,0 +1,2079 @@
1
+ import { defineStore } from "pinia";
2
+ export const useCustomeScriptDynamic = defineStore("CustomScriptDynamic", {
3
+ state: () => ({
4
+ SelectedOptions: { aid: null, gid: null, vid: null, fraction: false },
5
+ attributeIdz: null,
6
+ lookupprices: null,
7
+ servicePriceSetting: {},
8
+ conditions: null,
9
+ TYPES: null,
10
+ PRICETYPE: null,
11
+ UNIT_RELATIVE: null,
12
+ DISCOUNTS: null,
13
+ measurementUnit: null,
14
+ B2BTYPE: null,
15
+ USEBASEPRICE: null,
16
+ BASEPRICE: null,
17
+ usefitting: null,
18
+ sevice_price_type: null,
19
+ serviceprice: 0,
20
+ With_this_selection_following_selections_will_be_changed: "With this selection following selections will be changed \n",
21
+ attributeOf: ".attributeof",
22
+ attributeValuesClass: ".attributevalue",
23
+ attributeClass: ".attribute",
24
+ attributeClassName: "attribute",
25
+ valueClassName: "value",
26
+ valueClass: ".value",
27
+ valueChildClass: ".child",
28
+ groupClassName: "group",
29
+ groupClass: ".group",
30
+ priceClass: ".price .price_span",
31
+ rrpriceClass: ".price .price_span",
32
+ qtyElement: "#blind-product-form #quantity",
33
+ rrpriceWrapper: ".price .if-discounted",
34
+ imageElement: ".swatch-image-change img",
35
+ useBackground: false,
36
+ pdpsummary: {},
37
+ msgStr: {},
38
+ productPrice: 0,
39
+ productDiscountedPrice: 0,
40
+ confirmPopup: false,
41
+ promotionSettings: null,
42
+ linked_promotionSettings: null,
43
+ promotion_excludes: [],
44
+ total_values_discount: 0,
45
+ exclude_from_promo_total: 0,
46
+ renderdValues: 0,
47
+ sampleproduct: {},
48
+ findprice: "",
49
+ price_by_attributes: [],
50
+ price_by_attributeobject: [],
51
+ attributepriceobject: [],
52
+ attributeprices: [],
53
+ overlayimages: []
54
+ }),
55
+ actions: {
56
+ CallScriptFIrstTime() {
57
+ this.processAttributes();
58
+ this.setConditions("", true);
59
+ let hasnewMeasurements = this.setWidthHeightbaseonStyle();
60
+ if (hasnewMeasurements) {
61
+ this.setConditions("", true);
62
+ }
63
+ this.calculatePrice();
64
+ },
65
+ async initprocess() {
66
+ this.total_values_discount = 0;
67
+ this.exclude_from_promo_total = 0;
68
+ let gid = this.SelectedOptions.gid;
69
+ let aid = this.SelectedOptions.aid;
70
+ let vid = this.SelectedOptions.vid;
71
+ this.msgStr = {};
72
+ this.findprice = "";
73
+ this.price_by_attributes = [];
74
+ this.price_by_attributeobject = [];
75
+ this.attributepriceobject = [];
76
+ this.attributeprices = [];
77
+ var current_selected = Object.values(this.attributeIdz[aid]["values"]).find((v) => v.selected === true && v.applyhidden === false && v.shouldhidden === false);
78
+ if (current_selected !== void 0) {
79
+ if (this.attributeIdz[aid].type === this.TYPES["width"] || this.attributeIdz[aid].type === this.TYPES["subwidth"] || this.attributeIdz[aid].type === this.TYPES["height"] || this.attributeIdz[aid].type === this.TYPES["subheight"] || this.attributeIdz[aid].type === this.TYPES["number"] || this.attributeIdz[aid].type === this.TYPES["text"] || this.attributeIdz[aid].type === this.TYPES["message"]) {
80
+ let currentValue = this.attributeIdz[aid]["values"][current_selected.id]["value"];
81
+ this.attributeIdz[aid]["values"][current_selected.id]["ovalue"] = currentValue;
82
+ if (this.attributeIdz[aid].type !== this.TYPES["text"] && this.attributeIdz[aid].type !== this.TYPES["message"] && this.SelectedOptions.fraction == false) {
83
+ vid = parseFloat(vid);
84
+ }
85
+ this.attributeIdz[aid]["values"][current_selected.id]["value"] = vid;
86
+ this.setSummery(this.attributeIdz[aid], current_selected);
87
+ } else {
88
+ if (this.attributeIdz[aid].type === this.TYPES["drop-down"] || this.attributeIdz[aid].type === this.TYPES["style"] || this.attributeIdz[aid].type === this.TYPES["swatch"]) {
89
+ if (this.attributeIdz[aid].parent_id) {
90
+ var current_old_selected = Object.values(this.attributeIdz[aid]["values"]).find((v) => v.oldselected == true && v.parent_id == current_selected.parent_id);
91
+ } else {
92
+ var current_old_selected = Object.values(this.attributeIdz[aid]["values"]).find((v) => v.oldselected == true);
93
+ }
94
+ if (current_old_selected != void 0) {
95
+ this.attributeIdz[aid]["values"][current_old_selected.id]["oldselected"] = false;
96
+ }
97
+ this.attributeIdz[aid]["values"][current_selected.id]["selected"] = false;
98
+ this.attributeIdz[aid]["values"][current_selected.id]["oldselected"] = true;
99
+ }
100
+ }
101
+ }
102
+ var newvalue = Object.values(this.attributeIdz[aid]["values"]).find((v) => v.id === vid);
103
+ if (newvalue !== void 0 && (this.attributeIdz[aid].type === this.TYPES["drop-down"] || this.attributeIdz[aid].type === this.TYPES["style"] || this.attributeIdz[aid].type === this.TYPES["swatch"])) {
104
+ this.attributeIdz[aid]["values"][newvalue.id]["selected"] = true;
105
+ this.attributeIdz[aid]["values"][newvalue.id]["oldselected"] = false;
106
+ if (this.attributeIdz[aid].type === this.TYPES["width"] || this.attributeIdz[aid].type === this.TYPES["subwidth"] || this.attributeIdz[aid].type === this.TYPES["height"] || this.attributeIdz[aid].type === this.TYPES["subheight"]) {
107
+ this.markSelected(aid, newvalue.value);
108
+ } else {
109
+ this.markSelected(aid, newvalue.id);
110
+ }
111
+ this.setSummery(this.attributeIdz[aid], newvalue);
112
+ }
113
+ var allattribs = Object.values(this.attributeIdz).filter((a) => a.parent_id === aid);
114
+ allattribs = allattribs.sort((a, b) => a.gsortorder - b.gsortorder || a.sortorder - b.sortorder);
115
+ this.processAttribute(allattribs);
116
+ this.setConditions(aid, false);
117
+ let hasnewMeasurements = this.setWidthHeightbaseonStyle();
118
+ if (hasnewMeasurements) {
119
+ this.setConditions(aid, false);
120
+ }
121
+ this.calculatePrice();
122
+ this.calculateservicePrice();
123
+ this.swatchimage();
124
+ },
125
+ getAvailableValues(aid, parent_value_id = -1) {
126
+ if (parent_value_id != -1) {
127
+ return Object.values(this.attributeIdz[aid]["values"]).filter((v) => v.selected == false && v.parent_id == parent_value_id && v.shouldhidden == false && v.applyhidden == false);
128
+ }
129
+ return Object.values(this.attributeIdz[aid]["values"]).filter((v) => v.selected == false && v.shouldhidden == false && v.applyhidden == false);
130
+ },
131
+ setWidthHeightbaseonStyle() {
132
+ const style_attributes = Object.values(this.attributeIdz).filter((a) => a.type == this.TYPES["style"] && a.hide == 0);
133
+ let hasChanged = false;
134
+ if (style_attributes.length > 0) {
135
+ let minwidths = [];
136
+ let maxwidths = [];
137
+ let minheights = [];
138
+ let maxheights = [];
139
+ style_attributes.forEach((attribute) => {
140
+ const selectedv = Object.values(attribute["values"]).find((v) => v.selected == true && v.applyhidden == false && v.shouldhidden == false);
141
+ if (selectedv !== void 0) {
142
+ if (selectedv.enable_dimensions) {
143
+ maxheights.push(selectedv.max_height);
144
+ minheights.push(selectedv.min_height);
145
+ maxwidths.push(selectedv.max_width);
146
+ minwidths.push(selectedv.min_width);
147
+ }
148
+ }
149
+ });
150
+ const min_width = Math.max(...minwidths);
151
+ const max_width = Math.max(...maxwidths);
152
+ const min_height = Math.max(...minheights);
153
+ const max_height = Math.max(...maxheights);
154
+ if (min_width !== void 0 && min_width > 0 && max_width !== void 0 && max_width > 0) {
155
+ const findwidth = Object.values(this.attributeIdz).find((a) => a.type == this.TYPES["width"]);
156
+ if (findwidth !== void 0) {
157
+ const value_ids = Object.keys(this.attributeIdz[findwidth.id]["values"]);
158
+ if (value_ids.length > 0 && value_ids[0] !== void 0) {
159
+ const vid = value_ids[0];
160
+ this.attributeIdz[findwidth.id]["values"][vid]["min_width"] = min_width;
161
+ this.attributeIdz[findwidth.id]["values"][vid]["max_width"] = max_width;
162
+ let value = this.attributeIdz[findwidth.id]["values"][vid]["value"];
163
+ this.attributeIdz[findwidth.id]["values"][vid]["ovalue"] = value;
164
+ let newvalue = value;
165
+ if (value < min_width) {
166
+ newvalue = min_width;
167
+ }
168
+ if (value > max_width) {
169
+ newvalue = max_width;
170
+ }
171
+ if (value != newvalue) {
172
+ hasChanged = true;
173
+ }
174
+ this.attributeIdz[findwidth.id]["values"][vid]["value"] = newvalue;
175
+ const widthElement = document.querySelector(this.attributeClass + findwidth.id);
176
+ if (widthElement) {
177
+ widthElement.value = newvalue;
178
+ widthElement.setAttribute("value", newvalue);
179
+ }
180
+ }
181
+ }
182
+ }
183
+ if (min_height !== void 0 && min_height > 0 && max_height !== void 0 && max_height > 0) {
184
+ const findheight = Object.values(this.attributeIdz).find((a) => a.type == this.TYPES["height"]);
185
+ if (findheight !== void 0) {
186
+ const value_ids = Object.keys(this.attributeIdz[findheight.id]["values"]);
187
+ if (value_ids.length > 0 && value_ids[0] !== void 0) {
188
+ const vid = value_ids[0];
189
+ this.attributeIdz[findheight.id]["values"][vid]["min_height"] = min_height;
190
+ this.attributeIdz[findheight.id]["values"][vid]["max_height"] = max_height;
191
+ let value = this.attributeIdz[findheight.id]["values"][vid]["value"];
192
+ this.attributeIdz[findheight.id]["values"][vid]["ovalue"] = value;
193
+ let newvalue = value;
194
+ if (value < min_height) {
195
+ newvalue = min_height;
196
+ }
197
+ if (value > max_height) {
198
+ newvalue = max_height;
199
+ }
200
+ if (value != newvalue) {
201
+ hasChanged = true;
202
+ }
203
+ this.attributeIdz[findheight.id]["values"][vid]["value"] = newvalue;
204
+ const heightElement = document.querySelector(this.attributeClass + findheight.id);
205
+ if (heightElement) {
206
+ heightElement.value = newvalue;
207
+ heightElement.setAttribute("value", newvalue);
208
+ }
209
+ }
210
+ }
211
+ }
212
+ return hasChanged;
213
+ }
214
+ return false;
215
+ },
216
+ setSummery(attrib, value) {
217
+ let title = "";
218
+ if (attrib["type"] == this.TYPES["width"] || attrib["type"] == this.TYPES["subwidth"] || attrib["type"] == this.TYPES["height"] || attrib["type"] == this.TYPES["subheight"]) {
219
+ var fraction = "";
220
+ if ((value["fraction"] === 1 || value["fraction"] === "1") && (value["fvalue"] != "" && value["fvalue"] != null && value["fvalue"] != "0")) {
221
+ fraction = " " + value["fvalue"] + " ";
222
+ }
223
+ title = parseFloat(value["value"]) + fraction + " " + this.measurementUnit;
224
+ } else if (attrib["type"] == this.TYPES["number"] || attrib["type"] == this.TYPES["message"] || attrib["type"] == this.TYPES["text"]) {
225
+ title = value["value"];
226
+ } else {
227
+ title = value["title"];
228
+ }
229
+ if (!attrib.hide) {
230
+ this.pdpsummary[attrib["id"]] = { "attribute": attrib["title"], "value": title, "gsortorder": attrib["gsortorder"], "sortorder": attrib["sortorder"], "active": attrib["active"], "show_summary": attrib["show_summary"], "hide": attrib["hide"] };
231
+ }
232
+ },
233
+ unsetSummery(aid) {
234
+ delete this.pdpsummary[aid];
235
+ },
236
+ hideValue(h_aid, h_vid) {
237
+ this.markUnselected(h_aid, h_vid);
238
+ },
239
+ showValue(h_aid, h_vid) {
240
+ const element = document.querySelector(`${this.attributeClass + h_aid} [data-value="${h_vid}"]`);
241
+ if (element) {
242
+ element.parentElement.style.display = "";
243
+ element.removeAttribute("disabled");
244
+ element.style.display = "";
245
+ }
246
+ },
247
+ showAttribute(aid) {
248
+ const element = document.querySelector(this.attributeClass + aid);
249
+ if (element) {
250
+ element.style.display = "";
251
+ }
252
+ },
253
+ hideAttribute(aid) {
254
+ this.unsetSummery(aid);
255
+ const element = document.querySelector(this.attributeClass + aid);
256
+ if (element) {
257
+ element.style.display = "none";
258
+ }
259
+ },
260
+ hideChildValues(aid, parent_id) {
261
+ const childElements = document.querySelectorAll(`${this.attributeClass + aid} [data-attributevalue="${parent_id}"]`);
262
+ childElements.forEach((element) => {
263
+ let grandparent = element.parentElement?.parentElement;
264
+ element.selected = false;
265
+ element.checked = false;
266
+ element.removeAttribute("selected");
267
+ element.removeAttribute("checked");
268
+ element.classList.remove("active");
269
+ element.style.display = "none";
270
+ element.parentElement.style.display = "none";
271
+ if (grandparent && grandparent.classList.contains("swiper-slide")) {
272
+ grandparent.parentElement.style.display = "none";
273
+ }
274
+ element.disabled = true;
275
+ });
276
+ },
277
+ hideChildValuesOfParentValue(aid, parent_attribute_id, parent_value_id) {
278
+ const elements = document.querySelectorAll(`[data-attributevalue="${parent_attribute_id}"][data-child="${parent_value_id}"]`);
279
+ elements.forEach((element) => {
280
+ let grandparent = element.parentElement?.parentElement;
281
+ element.selected = false;
282
+ element.checked = false;
283
+ element.removeAttribute("selected");
284
+ element.removeAttribute("checked");
285
+ element.classList.remove("active");
286
+ element.style.display = "none";
287
+ element.parentElement.style.display = "none";
288
+ if (grandparent && grandparent.classList.contains("swiper-slide")) {
289
+ grandparent.parentElement.style.display = "none";
290
+ }
291
+ element.disabled = true;
292
+ });
293
+ },
294
+ showChildValues(aid, parent_selected_val_id) {
295
+ const childElements = document.querySelectorAll(`${this.attributeClass + aid} [data-child="${parent_selected_val_id}"]`);
296
+ childElements.forEach((element) => {
297
+ let grandparent = element.parentElement?.parentElement;
298
+ element.removeAttribute("disabled");
299
+ element.parentElement.style.display = "";
300
+ if (grandparent && grandparent.classList.contains("swiper-slide")) {
301
+ grandparent.parentElement.style.display = "";
302
+ }
303
+ element.style.display = "";
304
+ });
305
+ },
306
+ showGroup(gid) {
307
+ const groupElement = document.querySelector(this.groupClass + gid);
308
+ if (groupElement) {
309
+ groupElement.style.display = "";
310
+ }
311
+ },
312
+ hideGroup(gid) {
313
+ document.querySelector(this.groupClass + gid).style.display = "none";
314
+ },
315
+ markSelected(h_aid, h_vid) {
316
+ const element = document.querySelector(`${this.attributeClass}${h_aid} [data-value="${h_vid}"]`);
317
+ if (element) {
318
+ element.parentElement.style.display = "";
319
+ element.setAttribute("selected", true);
320
+ element.checked = true;
321
+ element.style.display = "";
322
+ element.classList.add("active");
323
+ if (element.getAttribute("customselect") == "true") {
324
+ element.dispatchEvent(new Event("change"));
325
+ }
326
+ }
327
+ const container = document.querySelector(`${this.attributeClass}${h_aid}`);
328
+ if (container) {
329
+ container.value = h_vid;
330
+ }
331
+ },
332
+ markInputSelected(aid, vid, value = null) {
333
+ const element = document.querySelector(this.attributeClass + aid);
334
+ const dataValueElement = element.querySelector('[data-value="' + vid + '"]');
335
+ if (dataValueElement) {
336
+ dataValueElement.setAttribute("selected", true);
337
+ dataValueElement.checked = true;
338
+ dataValueElement.style.display = "";
339
+ dataValueElement.classList.add("active");
340
+ }
341
+ if (value == 0 || value == "0") {
342
+ value = "";
343
+ }
344
+ element.value = value;
345
+ },
346
+ markUnselected(h_aid, h_vid) {
347
+ const element = document.querySelector(`${this.attributeClass + h_aid} [data-value="${h_vid}"]`);
348
+ if (element) {
349
+ element.parentElement.style.display = "none";
350
+ element.removeAttribute("selected");
351
+ element.checked = false;
352
+ element.style.display = "none";
353
+ element.classList.remove("active");
354
+ element.setAttribute("disabled", "true");
355
+ }
356
+ },
357
+ findSelectedValue(values, parent_value_id = -1) {
358
+ if (parent_value_id != -1) {
359
+ return Object.values(values).find((v) => v.selected == true && v.parent_id == parent_value_id && v.applyhidden == false && v.shouldhidden == false);
360
+ }
361
+ return Object.values(values).find((v) => v.selected == true && v.applyhidden == false && v.shouldhidden == false);
362
+ },
363
+ processAttributes() {
364
+ this.total_values_discount = 0;
365
+ this.productPrice = 0;
366
+ this.productDiscountedPrice = 0, this.msgStr = {};
367
+ this.findprice = "";
368
+ this.price_by_attributes = [];
369
+ this.price_by_attributeobject = [];
370
+ this.attributepriceobject = [];
371
+ this.attributeprices = [];
372
+ var allattribs = Object.values(this.attributeIdz).filter((a) => a.parent == null);
373
+ allattribs = allattribs.sort((a, b) => a.gsortorder - b.gsortorder || a.sortorder - b.sortorder);
374
+ this.processAttribute(allattribs);
375
+ },
376
+ processAttribute(attributes) {
377
+ const self = this;
378
+ if (attributes !== void 0 && attributes.length > 0) {
379
+ attributes.forEach((attrib) => {
380
+ if (attrib.values == void 0) {
381
+ return;
382
+ }
383
+ let selected_val2 = self.findSelectedValue(attrib.values);
384
+ let parent_id = attrib.parent_id;
385
+ if (parent_id && parent_id !== 0) {
386
+ self.hideAttribute(attrib.id);
387
+ let parent_selected_val = self.findSelectedValue(self.attributeIdz[parent_id]["values"]);
388
+ if (parent_selected_val !== void 0) {
389
+ self.showAttribute(attrib.id);
390
+ self.hideChildValues(attrib.id, parent_id);
391
+ self.showChildValues(attrib.id, parent_selected_val.id);
392
+ if (selected_val2 == void 0) {
393
+ let available_value_array = Object.values(self.attributeIdz[attrib.id]["values"]).filter((v) => v.parent_id == parent_selected_val.id && v.selected == false && v.applyhidden == false && v.shouldhidden == false);
394
+ if (available_value_array.length > 0) {
395
+ available_value_array.sort((a, b) => a.sortorder - b.sortorder);
396
+ selected_val2 = available_value_array[0];
397
+ self.attributeIdz[attrib.id]["values"][selected_val2.id]["selected"] = true;
398
+ self.attributeIdz[attrib.id]["values"][selected_val2.id]["oldselected"] = false;
399
+ self.setSummery(attrib, selected_val2);
400
+ if ([
401
+ self.TYPES["width"],
402
+ self.TYPES["subwidth"],
403
+ self.TYPES["height"],
404
+ self.TYPES["subheight"]
405
+ ].includes(self.attributeIdz[attrib.id].type)) {
406
+ self.markInputSelected(attrib.id, selected_val2.value);
407
+ } else {
408
+ self.markSelected(attrib.id, selected_val2.id);
409
+ }
410
+ } else {
411
+ selected_val2 = void 0;
412
+ self.hideAttribute(attrib.id);
413
+ self.hideAttributeHirerachy(attrib.id);
414
+ }
415
+ }
416
+ if (selected_val2 !== void 0 && selected_val2.parent_id !== parent_selected_val.id) {
417
+ self.attributeIdz[attrib.id]["values"][selected_val2.id]["selected"] = false;
418
+ self.attributeIdz[attrib.id]["values"][selected_val2.id]["oldselected"] = true;
419
+ let available_value_array = Object.values(self.attributeIdz[attrib.id]["values"]).filter((v) => v.parent_id == parent_selected_val.id && v.selected == false && v.applyhidden == false && v.shouldhidden == false);
420
+ if (available_value_array.length > 0) {
421
+ self.hideChildValues(attrib.id, parent_id);
422
+ self.showChildValues(attrib.id, parent_selected_val.id);
423
+ available_value_array.sort((a, b) => a.sortorder - b.sortorder);
424
+ selected_val2 = available_value_array[0];
425
+ self.attributeIdz[attrib.id]["values"][selected_val2.id]["selected"] = true;
426
+ self.attributeIdz[attrib.id]["values"][selected_val2.id]["oldselected"] = false;
427
+ self.setSummery(attrib, selected_val2);
428
+ if ([
429
+ self.TYPES["width"],
430
+ self.TYPES["subwidth"],
431
+ self.TYPES["height"],
432
+ self.TYPES["subheight"]
433
+ ].includes(self.attributeIdz[attrib.id].type)) {
434
+ self.markInputSelected(attrib.id, selected_val2.id, selected_val2.value);
435
+ } else {
436
+ self.markSelected(attrib.id, selected_val2.id);
437
+ }
438
+ } else {
439
+ selected_val2 = void 0;
440
+ self.hideAttribute(attrib.id);
441
+ self.hideAttributeHirerachy(attrib.id);
442
+ }
443
+ } else {
444
+ if (selected_val2 && selected_val2.parent_id == parent_selected_val.id) {
445
+ self.showChildValues(attrib.id, parent_selected_val.id);
446
+ }
447
+ if (selected_val2) {
448
+ if ([
449
+ self.TYPES["width"],
450
+ self.TYPES["subwidth"],
451
+ self.TYPES["height"],
452
+ self.TYPES["subheight"]
453
+ ].includes(self.attributeIdz[attrib.id].type)) {
454
+ self.markInputSelected(attrib.id, selected_val2.id, selected_val2.value);
455
+ } else {
456
+ self.markSelected(attrib.id, selected_val2.id);
457
+ }
458
+ }
459
+ }
460
+ } else {
461
+ self.hideChildValues(attrib.id, parent_id);
462
+ }
463
+ }
464
+ if (selected_val2) {
465
+ self.setSummery(attrib, selected_val2);
466
+ if (![self.TYPES["width"], self.TYPES["subwidth"], self.TYPES["height"], self.TYPES["subheight"], self.TYPES["number"], self.TYPES["message"], self.TYPES["text"]].includes(attrib["type"])) {
467
+ if ([
468
+ self.TYPES["width"],
469
+ self.TYPES["subwidth"],
470
+ self.TYPES["height"],
471
+ self.TYPES["subheight"]
472
+ ].includes(self.attributeIdz[attrib.id].type)) {
473
+ self.markInputSelected(attrib.id, selected_val2.id, selected_val2.value);
474
+ } else {
475
+ self.markSelected(attrib.id, selected_val2.id);
476
+ }
477
+ let child_attrib = Object.values(self.attributeIdz).filter((a) => a.parent == attrib["id"]);
478
+ if (child_attrib.length > 0) {
479
+ self.processChildAttribute(child_attrib);
480
+ }
481
+ }
482
+ }
483
+ });
484
+ }
485
+ },
486
+ processAttributeAfterCondition(attributes) {
487
+ let self = this;
488
+ if (attributes != void 0 && attributes.length > 0) {
489
+ Object.keys(attributes).forEach(function(key) {
490
+ if (attributes[key]["values"] == void 0) {
491
+ return;
492
+ }
493
+ let hiddenvalues = Object.values(attributes[key]["values"]).filter((v) => v.applyhidden == true || v.shouldhidden == true);
494
+ hiddenvalues.forEach(function(value, index) {
495
+ self.markUnselected(value.aid, value.id);
496
+ });
497
+ var child_attrib = Object.values(self.attributeIdz).filter((a) => a.parent_id == attributes[key].id);
498
+ if (child_attrib.length > 0) {
499
+ self.processAttributeAfterCondition(child_attrib);
500
+ }
501
+ });
502
+ }
503
+ },
504
+ hideAttributeHirerachy(aid) {
505
+ var child_attrib = Object.values(this.attributeIdz).filter((a) => a.parent == aid);
506
+ this.hideChildAttributes(child_attrib);
507
+ },
508
+ hideChildAttributes(child_attrib) {
509
+ const self = this;
510
+ child_attrib.forEach((cattrib) => {
511
+ const select_value = Object.values(cattrib["values"]).find((v) => v.selected == true && v.applyhidden == false);
512
+ if (select_value !== void 0) {
513
+ self.attributeIdz[cattrib.id]["values"][select_value.id]["selected"] = false;
514
+ self.attributeIdz[cattrib.id]["values"][select_value.id]["oldselected"] = true;
515
+ }
516
+ self.hideAttribute(cattrib["id"]);
517
+ const childattrib = Object.values(self.attributeIdz).filter((a) => a.parent == cattrib["id"]);
518
+ self.hideChildAttributes(childattrib);
519
+ });
520
+ },
521
+ processChildAttribute(child_attrib) {
522
+ child_attrib = child_attrib.sort((a, b) => a.gsortorder - b.gsortorder || a.sortorder - b.sortorder);
523
+ this.processAttribute(child_attrib);
524
+ },
525
+ async setConditions(aid = "", first_call2 = false) {
526
+ if (first_call2 == true) {
527
+ }
528
+ let available2 = 1;
529
+ let changed_attribs = {};
530
+ let response = true;
531
+ let self = this;
532
+ if (typeof self.attributeIdz !== "undefined") {
533
+ let msgAttributes = {};
534
+ let hiddenAttributes = {};
535
+ let childAttributes = {};
536
+ let changed_values2 = {};
537
+ self.conditions.forEach((condition_array) => {
538
+ let c_aid2 = condition_array.key;
539
+ let db_condition = condition_array.values;
540
+ let changed_values3 = {};
541
+ let hiddenValues2 = {};
542
+ let child_Values2 = {};
543
+ let msgValue2 = {};
544
+ Object.entries(db_condition).forEach(([v_id2, cond]) => {
545
+ let newcondition2 = self.createCondition(cond);
546
+ if (self.attributeIdz[c_aid2]?.values[v_id2]) {
547
+ let conditionReturn = self.executeCondition(
548
+ newcondition2,
549
+ c_aid2,
550
+ v_id2,
551
+ changed_values3,
552
+ msgValue2,
553
+ hiddenValues2,
554
+ child_Values2,
555
+ first_call2
556
+ );
557
+ changed_values3 = conditionReturn.changed_values;
558
+ msgValue2 = conditionReturn.msgValue;
559
+ hiddenValues2 = conditionReturn.hiddenValues;
560
+ child_Values2 = conditionReturn.child_Values;
561
+ }
562
+ if (Object.keys(msgValue2).length > 0) {
563
+ msgAttributes[c_aid2] = msgValue2;
564
+ }
565
+ if (Object.keys(changed_values3).length > 0) {
566
+ changed_attribs[c_aid2] = changed_values3;
567
+ }
568
+ if (Object.keys(hiddenValues2).length > 0) {
569
+ hiddenAttributes[c_aid2] = hiddenValues2;
570
+ }
571
+ if (Object.keys(child_Values2).length > 0) {
572
+ childAttributes[c_aid2] = child_Values2;
573
+ }
574
+ });
575
+ let selected_value_hidden_array = Object.values(self.attributeIdz[c_aid2]?.values || {}).filter(
576
+ (v) => v.selected && v.shouldhidden
577
+ );
578
+ if (selected_value_hidden_array.length > 0) {
579
+ self.selectOneValue(c_aid2);
580
+ selected_value_hidden_array.forEach((hidden_value) => {
581
+ self.attributeIdz[c_aid2].values[hidden_value.id].selected = false;
582
+ self.attributeIdz[c_aid2].values[hidden_value.id].oldselected = false;
583
+ self.markUnselected(c_aid2, hidden_value.id);
584
+ let conditionReturn = self.checkChangeAttributesMsg(
585
+ c_aid2,
586
+ msgAttributes,
587
+ msgValue2,
588
+ hidden_value,
589
+ child_Values2,
590
+ first_call2,
591
+ available2
592
+ );
593
+ child_Values2 = conditionReturn.child_Values;
594
+ if (Object.keys(child_Values2).length > 0) {
595
+ childAttributes[c_aid2] = child_Values2;
596
+ }
597
+ });
598
+ selected_value_hidden_array.sort((a, b) => a.sortorder - b.sortorder);
599
+ let pick_first_value = selected_value_hidden_array[0];
600
+ self.attributeIdz[c_aid2].values[pick_first_value.id].oldselected = true;
601
+ self.hideAttributeOrGroup(c_aid2);
602
+ } else {
603
+ self.selectOneValue(c_aid2);
604
+ }
605
+ });
606
+ if ((Object.values(msgAttributes).length > 0 || Object.values(childAttributes).length > 0) && !first_call2) {
607
+ response = true;
608
+ if (Object.values(msgAttributes).length > 0) {
609
+ response = await self.confirmChange(changed_attribs, hiddenAttributes, aid);
610
+ }
611
+ Object.entries(childAttributes).forEach(([a_id, a_values]) => {
612
+ a_id = Number(a_id);
613
+ let gid = self.attributeIdz[a_id]?.gid || 1;
614
+ Object.entries(a_values).forEach(([v_id2, value]) => {
615
+ v_id2 = Number(v_id2);
616
+ if (value.confirm_popup) {
617
+ if (response) {
618
+ if (value.selected && value.show && value.child > 0) {
619
+ self.markSelected(a_id, v_id2);
620
+ let child_attribute = Object.values(self.attributeIdz).filter(
621
+ (a) => a.parent_id === a_id && !a.hide
622
+ );
623
+ self.processAttribute(child_attribute);
624
+ }
625
+ if (!value.selected && value.hide && value.child > 0) {
626
+ let child_attribute = Object.values(self.attributeIdz).filter(
627
+ (a) => a.parent_id === a_id && !a.hide
628
+ );
629
+ if (child_attribute.length > 0) {
630
+ child_attribute.forEach((attribute) => {
631
+ let child_selected = Object.values(attribute.values).find(
632
+ (v) => v.parent_id === v_id2 && v.selected
633
+ );
634
+ self.hideChildValuesOfParentValue(attribute.id, a_id, v_id2);
635
+ if (child_selected) {
636
+ self.attributeIdz[attribute.id].values[child_selected.id].selected = false;
637
+ self.markUnselected(attribute.id, child_selected.id);
638
+ }
639
+ let find_any_selected = Object.values(attribute.values).find(
640
+ (v) => v.selected && !v.applyhidden && !v.shouldhidden
641
+ );
642
+ if (!find_any_selected) {
643
+ self.hideAttributeOrGroup(attribute.id);
644
+ self.hideAttribute(attribute.id);
645
+ self.unsetMsg(attribute.id);
646
+ }
647
+ });
648
+ }
649
+ }
650
+ }
651
+ } else {
652
+ if (!value.selected) {
653
+ if (value.hide && value.child > 0) {
654
+ self.markUnselected(a_id, v_id2);
655
+ let child_attribute = Object.values(self.attributeIdz).filter(
656
+ (a) => a.parent_id === a_id && !a.hide
657
+ );
658
+ if (child_attribute.length > 0) {
659
+ child_attribute.forEach((attribute) => {
660
+ let child_selected = Object.values(attribute.values).find(
661
+ (v) => v.parent_id === v_id2 && v.selected
662
+ );
663
+ self.hideChildValuesOfParentValue(attribute.id, a_id, v_id2);
664
+ if (child_selected) {
665
+ self.attributeIdz[attribute.id].values[child_selected.id].selected = false;
666
+ self.markUnselected(attribute.id, child_selected.id);
667
+ }
668
+ let find_any_selected = Object.values(attribute.values).find(
669
+ (v) => v.selected && !v.applyhidden && !v.shouldhidden
670
+ );
671
+ if (!find_any_selected) {
672
+ self.hideAttributeOrGroup(attribute.id);
673
+ self.hideAttribute(attribute.id);
674
+ self.unsetMsg(attribute.id);
675
+ }
676
+ });
677
+ }
678
+ } else if (value.show) {
679
+ if (value.child > 0) {
680
+ let child_attribute = Object.values(self.attributeIdz).filter(
681
+ (a) => a.parent_id === a_id && !a.hide
682
+ );
683
+ self.processAttribute(child_attribute);
684
+ self.processAttributeAfterCondition(child_attribute);
685
+ } else {
686
+ let child_attribute = Object.values(self.attributeIdz).filter(
687
+ (a) => a.parent_id === a_id && !a.hide
688
+ );
689
+ child_attribute.forEach((attribute) => {
690
+ if (attribute.parent_id) {
691
+ let find_selectedValue = Object.values(
692
+ self.attributeIdz[attribute.parent_id]?.values || {}
693
+ ).find(
694
+ (v) => v.selected && !v.applyhidden && !v.shouldhidden
695
+ );
696
+ let find_Value = Object.values(attribute.values).find(
697
+ (v) => v.selected && !v.applyhidden && !v.shouldhidden
698
+ );
699
+ if (!find_Value) {
700
+ self.markUnselected(attribute.id, v_id2);
701
+ self.hideAttributeOrGroup(attribute.id);
702
+ self.hideAttribute(attribute.id);
703
+ self.unsetMsg(attribute.id);
704
+ } else if (!find_selectedValue || find_selectedValue && find_selectedValue.id !== attribute.values[find_Value.id].parent_id) {
705
+ self.markUnselected(attribute.id, v_id2);
706
+ self.hideAttributeOrGroup(attribute.id);
707
+ self.hideAttribute(attribute.id);
708
+ self.unsetMsg(attribute.id);
709
+ }
710
+ }
711
+ });
712
+ }
713
+ }
714
+ } else if (value.selected) {
715
+ if (value.show) {
716
+ if (value.child > 0) {
717
+ self.showAttribute(a_id);
718
+ let child_attribute = Object.values(self.attributeIdz).filter(
719
+ (a) => a.parent_id === a_id && !a.hide
720
+ );
721
+ child_attribute.forEach((attribute) => {
722
+ let has_child_values = Object.values(attribute.values).filter(
723
+ (v) => v.parent_id === v_id2 && !v.shouldhidden && !v.applyhidden
724
+ );
725
+ if (has_child_values.length > 0) {
726
+ self.showAttribute(attribute.id);
727
+ }
728
+ });
729
+ }
730
+ }
731
+ }
732
+ }
733
+ });
734
+ });
735
+ }
736
+ }
737
+ return response;
738
+ },
739
+ // setConditions(aid = '', first_call = false) {
740
+ // let self = this;
741
+ // let available = 1;
742
+ // let changed_attribs = {};
743
+ // let response = true;
744
+ // if (self.attributeIdz !== undefined) {
745
+ // let msgAttributes = {};
746
+ // let hiddenAttributes = {};
747
+ // let childAttributes = {};
748
+ // (self.conditions).forEach(function (condition_array) {
749
+ // let c_aid = condition_array.key;
750
+ // let db_condition = condition_array.values;
751
+ // let changed_values = {};
752
+ // let hiddenValues = {};
753
+ // let child_Values = {};
754
+ // let msgValue = {};
755
+ // Object.entries(db_condition).forEach(function (cond, v_id) {
756
+ // let newcondition = self.createCondition(cond);
757
+ // if (self.attributeIdz[c_aid]['values'][v_id] !== undefined) {
758
+ // let conditionReturn = self.executeCondition(
759
+ // newcondition,
760
+ // c_aid,
761
+ // v_id,
762
+ // changed_values,
763
+ // msgValue,
764
+ // hiddenValues,
765
+ // child_Values,
766
+ // first_call
767
+ // );
768
+ // changed_values = conditionReturn['changed_values'];
769
+ // msgValue = conditionReturn['msgValue'];
770
+ // hiddenValues = conditionReturn['hiddenValues'];
771
+ // child_Values = conditionReturn['child_Values'];
772
+ // }
773
+ // if (Object.keys(msgValue).length > 0) {
774
+ // msgAttributes[c_aid] = msgValue;
775
+ // }
776
+ // if (Object.keys(changed_values).length > 0) {
777
+ // changed_attribs[c_aid] = changed_values;
778
+ // }
779
+ // if (Object.keys(hiddenValues).length > 0) {
780
+ // hiddenAttributes[c_aid] = hiddenValues;
781
+ // }
782
+ // if (Object.keys(child_Values).length > 0) {
783
+ // childAttributes[c_aid] = child_Values;
784
+ // }
785
+ // });
786
+ // let selected_value_hidden_array = Object.values(self.attributeIdz[c_aid]['values']).filter(
787
+ // (v) => v.selected === true && v.shouldhidden === true
788
+ // );
789
+ // if (selected_value_hidden_array.length > 0) {
790
+ // self.selectOneValue(c_aid);
791
+ // selected_value_hidden_array.forEach(function (hidden_value) {
792
+ // self.attributeIdz[c_aid]['values'][hidden_value.id]['selected'] = false;
793
+ // self.attributeIdz[c_aid]['values'][hidden_value.id]['oldselected'] = false;
794
+ // self.markUnselected(c_aid, hidden_value.id);
795
+ // let conditionReturn = self.checkChangeAttributesMsg(
796
+ // c_aid,
797
+ // msgAttributes,
798
+ // msgValue,
799
+ // hidden_value,
800
+ // child_Values,
801
+ // first_call,
802
+ // available
803
+ // );
804
+ // child_Values = conditionReturn['child_Values'];
805
+ // if (Object.keys(child_Values).length > 0) {
806
+ // childAttributes[c_aid] = child_Values;
807
+ // }
808
+ // });
809
+ // selected_value_hidden_array.sort((a, b) => a.sortorder - b.sortorder);
810
+ // let pick_first_value = selected_value_hidden_array[0];
811
+ // self.attributeIdz[c_aid]['values'][pick_first_value.id]['oldselected'] = true;
812
+ // self.hideAttributeOrGroup(c_aid);
813
+ // } else {
814
+ // self.selectOneValue(c_aid);
815
+ // }
816
+ // });
817
+ // if (
818
+ // (Object.values(self.msgStr).length > 0 || Object.values(childAttributes).length > 0) &&
819
+ // first_call === false
820
+ // ) {
821
+ // response = true;
822
+ // if (Object.values(msgStr).length > 0) {
823
+ // response = self.confirmChange(changed_attribs, hiddenAttributes, aid);
824
+ // }
825
+ // for (let a_id in childAttributes) {
826
+ // let a_values = childAttributes[a_id];
827
+ // let gid = self.attributeIdz[a_id] ? self.attributeIdz[a_id]['gid'] : 1;
828
+ // for (let v_id in a_values) {
829
+ // let value = a_values[v_id];
830
+ // if (value.confirmation_popup === true) {
831
+ // if (response === true) {
832
+ // if (value.selected === true && value.show === true && value.child > 0) {
833
+ // self.markSelected(a_id, v_id);
834
+ // let child_attribute = Object.values(self.attributeIdz).filter(
835
+ // (a) => a.parent_id === a_id && a.hide === 0
836
+ // );
837
+ // self.processAttribute(child_attribute);
838
+ // }
839
+ // if (value.selected === false && value.hide === true && value.child > 0) {
840
+ // let child_attribute = Object.values(self.attributeIdz).filter(
841
+ // (a) => a.parent_id === a_id && a.hide === 0
842
+ // );
843
+ // if (child_attribute.length > 0) {
844
+ // child_attribute.forEach(function (attribute) {
845
+ // let child_selected = Object.values(attribute['values']).find(
846
+ // (v) => v.parent_id === v_id && v.selected === true
847
+ // );
848
+ // self.hideChildValuesOfParentValue(attribute.id, a_id, v_id);
849
+ // if (child_selected !== undefined) {
850
+ // self.attributeIdz[attribute.id]['values'][child_selected.id]['selected'] = false;
851
+ // self.markUnselected(attribute.id, child_selected.id);
852
+ // }
853
+ // let find_any_selected = Object.values(attribute['values']).find(
854
+ // (v) =>
855
+ // v.selected === true &&
856
+ // v.applyhidden === false &&
857
+ // v.shouldhidden === false
858
+ // );
859
+ // if (find_any_selected === undefined) {
860
+ // self.hideAttributeOrGroup(attribute.id);
861
+ // self.hideAttribute(attribute.id);
862
+ // self.unsetMsg(attribute.id);
863
+ // }
864
+ // });
865
+ // }
866
+ // }
867
+ // } else {
868
+ // if (value.selected === false && value.hide === true && value.child > 0) {
869
+ // // Handle variations if needed
870
+ // } else if (value.selected === true) {
871
+ // // Clear child values
872
+ // }
873
+ // }
874
+ // } else if (value.confirmation_popup === false) {
875
+ // if (value.selected === false) {
876
+ // if (value.hide === true && value.child > 0) {
877
+ // self.markUnselected(a_id, v_id);
878
+ // let child_attribute = Object.values(self.attributeIdz).filter(
879
+ // (a) => a.parent_id === a_id && a.hide === 0
880
+ // );
881
+ // if (child_attribute.length > 0) {
882
+ // child_attribute.forEach(function (attribute) {
883
+ // let child_selected = Object.values(attribute['values']).find(
884
+ // (v) => v.parent_id === v_id && v.selected === true
885
+ // );
886
+ // self.hideChildValuesOfParentValue(attribute.id, a_id, v_id);
887
+ // if (child_selected !== undefined) {
888
+ // self.attributeIdz[attribute.id]['values'][child_selected.id]['selected'] = false;
889
+ // self.markUnselected(attribute.id, child_selected.id);
890
+ // }
891
+ // let find_any_selected = Object.values(attribute['values']).find(
892
+ // (v) =>
893
+ // v.selected === true &&
894
+ // v.applyhidden === false &&
895
+ // v.shouldhidden === false
896
+ // );
897
+ // if (find_any_selected === undefined) {
898
+ // self.hideAttributeOrGroup(attribute.id);
899
+ // self.hideAttribute(attribute.id);
900
+ // self.unsetMsg(attribute.id);
901
+ // }
902
+ // });
903
+ // }
904
+ // } else if (value.show === true) {
905
+ // if (value.child > 0) {
906
+ // let child_attribute = Object.values(self.attributeIdz).filter(
907
+ // (a) => a.parent_id === a_id && a.hide === 0
908
+ // );
909
+ // self.processAttribute(child_attribute);
910
+ // self.processAttributeAfterCondition(child_attribute);
911
+ // } else {
912
+ // let child_attribute = Object.values(self.attributeIdz).filter(
913
+ // (a) => a.parent_id === a_id && a.hide === 0
914
+ // );
915
+ // child_attribute.forEach(function (attribute) {
916
+ // if (attribute.parent_id) {
917
+ // let find_selectedValue = Object.values(self.attributeIdz[attribute.parent_id]['values']).find(
918
+ // (v) =>
919
+ // v.selected === true &&
920
+ // v.applyhidden === false &&
921
+ // v.shouldhidden === false
922
+ // );
923
+ // let find_Value = Object.values(attribute['values']).find(
924
+ // (v) =>
925
+ // v.selected === true &&
926
+ // v.applyhidden === false &&
927
+ // v.shouldhidden === false
928
+ // );
929
+ // if (find_Value === undefined) {
930
+ // self.markUnselected(attribute.id, v_id);
931
+ // self.hideAttributeOrGroup(attribute.id);
932
+ // self.hideAttribute(attribute.id);
933
+ // self.unsetMsg(attribute.id);
934
+ // } else if (
935
+ // find_selectedValue === undefined ||
936
+ // (find_selectedValue &&
937
+ // find_selectedValue.id !== attribute['values'][find_Value.id].parent_id)
938
+ // ) {
939
+ // self.markUnselected(attribute.id, v_id);
940
+ // self.hideAttributeOrGroup(attribute.id);
941
+ // self.hideAttribute(attribute.id);
942
+ // self.unsetMsg(attribute.id);
943
+ // }
944
+ // }
945
+ // });
946
+ // }
947
+ // }
948
+ // } else if (value.selected === true) {
949
+ // if (value.show === true) {
950
+ // if (value.child > 0) {
951
+ // self.showAttribute(a_id);
952
+ // let child_attribute = Object.values(self.attributeIdz).filter(
953
+ // (a) => a.parent_id === a_id && a.hide === 0
954
+ // );
955
+ // child_attribute.forEach(function (attribute) {
956
+ // let has_child_values = Object.values(attribute['values']).filter(
957
+ // (v) =>
958
+ // v.parent_id === v_id &&
959
+ // v.shouldhidden === false &&
960
+ // v.applyhidden === false
961
+ // );
962
+ // if (has_child_values.length) {
963
+ // self.showAttribute(attribute.id);
964
+ // }
965
+ // });
966
+ // }
967
+ // }
968
+ // }
969
+ // }
970
+ // }
971
+ // }
972
+ // }
973
+ // }
974
+ // return response;
975
+ // },
976
+ createCondition(conditionArray) {
977
+ let newcondition2 = conditionArray["condition"];
978
+ let appliedon = conditionArray["appliedon"];
979
+ for (const con_aid in appliedon) {
980
+ let findattrib = Object.values(this.attributeIdz).find((a) => a.id == con_aid);
981
+ if (findattrib) {
982
+ if (findattrib.type == this.TYPES["width"] || findattrib.type == this.TYPES["subwidth"] || findattrib.type == this.TYPES["height"] || findattrib.type == this.TYPES["subheight"]) {
983
+ let fraction = "0.00";
984
+ let value = 0;
985
+ let vid = Object.keys(this.attributeIdz[findattrib.id]["values"]);
986
+ if (vid != void 0 && vid.length > 0) {
987
+ value = this.attributeIdz[findattrib.id]["values"][vid[0]].value;
988
+ }
989
+ newcondition2 = newcondition2.replaceAll("attribute" + con_aid, value);
990
+ } else {
991
+ let findvalue = Object.values(findattrib["values"]).find((fv) => fv.selected == true && fv.shouldhidden == false && fv.applyhidden == false);
992
+ if (findvalue) {
993
+ newcondition2 = newcondition2.replaceAll("attribute" + con_aid, findvalue.id);
994
+ } else {
995
+ newcondition2 = newcondition2.replaceAll("attribute" + con_aid, "'empty'");
996
+ }
997
+ }
998
+ }
999
+ }
1000
+ return newcondition2;
1001
+ },
1002
+ getelement(classname) {
1003
+ var element = document.getElementsByClassName(classname);
1004
+ return element.length ? element[0] : void 0;
1005
+ },
1006
+ toggle(classname) {
1007
+ var element = document.getElementsByClassName(classname);
1008
+ return element.length ? element[0] : void 0;
1009
+ },
1010
+ getvalue(classname) {
1011
+ var element = document.getElementsByClassName(classname);
1012
+ return element.length ? element[0].value : void 0;
1013
+ },
1014
+ executeCondition(newcondition, c_aid, v_id, changed_values, msgValue, hiddenValues, child_Values, first_call, available = 1) {
1015
+ var selected_val = this.attributeIdz[c_aid]["values"][v_id];
1016
+ if (selected_val.selected == false) {
1017
+ if (eval(newcondition) == false) {
1018
+ if (this.attributeIdz[c_aid]["values"][v_id]["applyhidden"] == false) {
1019
+ changed_values[v_id] = this.attributeIdz[c_aid]["values"][v_id];
1020
+ }
1021
+ this.attributeIdz[c_aid]["values"][v_id]["applyhidden"] = true;
1022
+ this.attributeIdz[c_aid]["values"][v_id]["shouldhidden"] = false;
1023
+ this.markUnselected(c_aid, v_id);
1024
+ this.hideAttributeOrGroup(c_aid);
1025
+ let parent_attribute_id = c_aid;
1026
+ let child_attribute = Object.values(this.attributeIdz).filter((a) => a.parent == parent_attribute_id && a.hide == 0);
1027
+ if (child_attribute.length > 0) {
1028
+ child_attribute.forEach((attribute) => {
1029
+ let child_values = Object.values(attribute["values"]).filter((v) => v.parent_id == v_id);
1030
+ child_Values[v_id] = {
1031
+ v_id,
1032
+ selected: false,
1033
+ hide: true,
1034
+ confirm_popup: false,
1035
+ child: child_values.length
1036
+ };
1037
+ });
1038
+ }
1039
+ } else {
1040
+ let old_selected_value = this.attributeIdz[c_aid]["values"][v_id];
1041
+ if (old_selected_value["applyhidden"] == true) {
1042
+ hiddenValues[v_id] = { ...old_selected_value };
1043
+ }
1044
+ this.attributeIdz[c_aid]["values"][v_id]["applyhidden"] = false;
1045
+ this.attributeIdz[c_aid]["values"][v_id]["shouldhidden"] = false;
1046
+ let showTheValue = this.showValueAttributeOrGroup(c_aid, v_id);
1047
+ if (showTheValue) {
1048
+ let parent_attribute_id = c_aid;
1049
+ let child_attribute = Object.values(this.attributeIdz).filter((a) => a.parent == parent_attribute_id && a.hide == 0);
1050
+ if (child_attribute.length > 0) {
1051
+ child_attribute.forEach((attribute) => {
1052
+ let child_values = Object.values(attribute["values"]).filter((v) => v.parent_id == v_id);
1053
+ child_Values[v_id] = {
1054
+ v_id,
1055
+ selected: false,
1056
+ show: true,
1057
+ confirm_popup: false,
1058
+ child: child_values.length
1059
+ };
1060
+ });
1061
+ }
1062
+ }
1063
+ }
1064
+ } else {
1065
+ if (eval(newcondition) == false) {
1066
+ let old_selected_value = Object.values(this.attributeIdz[c_aid]["values"]).find((v) => v.oldselected == true && v.hide == 0 && v.shouldhidden == false && v.applyhidden == false);
1067
+ if (old_selected_value == void 0) {
1068
+ let old_selected_array = Object.values(this.attributeIdz[c_aid]["values"]).filter((v) => v.selected == false && v.hide == 0 && v.applyhidden == false && v.shouldhidden == false);
1069
+ if (old_selected_array.length > 0) {
1070
+ old_selected_array.sort((a, b) => a.sortorder - b.sortorder);
1071
+ old_selected_value = old_selected_array[0];
1072
+ }
1073
+ }
1074
+ if (old_selected_value !== void 0 && this.attributeIdz[c_aid].hide == 0 && first_call == false && available == 1) {
1075
+ if (this.attributeIdz[c_aid].confirm_popup == true) {
1076
+ msgValue[v_id] = this.attributeIdz[c_aid]["values"][v_id];
1077
+ let from = this.attributeIdz[c_aid]["values"][v_id].title;
1078
+ let to = old_selected_value !== void 0 ? old_selected_value.title : "";
1079
+ if (this.msgStr[c_aid] !== void 0) {
1080
+ const startPosition = this.msgStr[c_aid].lastIndexOf(" to ");
1081
+ let replacementText = " to " + to + ", \n";
1082
+ this.msgStr[c_aid] = this.msgStr[c_aid].slice(0, startPosition) + replacementText;
1083
+ } else {
1084
+ this.msgStr[c_aid] = this.attributeIdz[c_aid].title + ": " + from + " to " + to + ", \n";
1085
+ }
1086
+ }
1087
+ let parent_attribute_id = c_aid;
1088
+ let child_attribute = Object.values(this.attributeIdz).filter((a) => a.parent == parent_attribute_id && a.hide == 0);
1089
+ if (child_attribute.length > 0) {
1090
+ child_attribute.forEach((attribute) => {
1091
+ let from_has_child_values = Object.values(attribute["values"]).filter((v) => v.parent_id == v_id);
1092
+ let to_has_child_values = Object.values(attribute["values"]).filter((v) => v.parent_id == old_selected_value.id);
1093
+ child_Values[v_id] = {
1094
+ v_id,
1095
+ selected: false,
1096
+ hide: true,
1097
+ confirm_popup: true,
1098
+ child: from_has_child_values.length
1099
+ };
1100
+ child_Values[old_selected_value.id] = {
1101
+ v_id: old_selected_value.id,
1102
+ selected: true,
1103
+ show: true,
1104
+ confirm_popup: true,
1105
+ child: to_has_child_values.length
1106
+ };
1107
+ });
1108
+ }
1109
+ }
1110
+ changed_values[v_id] = this.attributeIdz[c_aid]["values"][v_id];
1111
+ this.attributeIdz[c_aid]["values"][v_id]["shouldhidden"] = true;
1112
+ this.attributeIdz[c_aid]["values"][v_id]["applyhidden"] = true;
1113
+ } else {
1114
+ this.attributeIdz[c_aid]["values"][v_id]["shouldhidden"] = false;
1115
+ this.attributeIdz[c_aid]["values"][v_id]["applyhidden"] = false;
1116
+ let showTheValue = this.showValueAttributeOrGroup(c_aid, v_id);
1117
+ if (showTheValue) {
1118
+ let parent_attribute_id = c_aid;
1119
+ let child_attribute = Object.values(this.attributeIdz).filter((a) => a.parent == parent_attribute_id && a.hide == 0);
1120
+ if (child_attribute.length > 0) {
1121
+ child_attribute.forEach((attribute) => {
1122
+ let child_values = Object.values(attribute["values"]).filter((v) => v.parent_id == v_id);
1123
+ child_Values[v_id] = {
1124
+ v_id,
1125
+ selected: true,
1126
+ show: true,
1127
+ confirm_popup: false,
1128
+ child: child_values.length
1129
+ };
1130
+ });
1131
+ }
1132
+ }
1133
+ }
1134
+ }
1135
+ return {
1136
+ msgValue,
1137
+ changed_values,
1138
+ hiddenValues,
1139
+ child_Values
1140
+ };
1141
+ },
1142
+ // hideAttributeOrGroup ( c_aid:any) {
1143
+ // let findSelected_Value='';
1144
+ // var pick_first_value = '';
1145
+ // var gid = '';
1146
+ // var group_attributes = '';
1147
+ // const self = this;
1148
+ // // find any select value if found we will not hide attribute and group
1149
+ // let findSelectedValue = Object.values ( this.attributeIdz[ c_aid ][ 'values' ] ).filter ( v => ( v.selected == true && v.applyhidden == false && v.shouldhidden == false ) );
1150
+ // // selected value in found retrun
1151
+ // if ( findSelectedValue.length )
1152
+ // return;
1153
+ // gid = this.attributeIdz[ c_aid ].gid;
1154
+ // // let available_value_array = Object.values ( this.attributeIdz[ c_aid ][ 'values' ] ).filter ( v => ( v.selected == false && v.applyhidden == false && v.shouldhidden == false ) );
1155
+ // let currentAttribute = this.attributeIdz[ c_aid ];
1156
+ // gid = currentAttribute.gid;
1157
+ // let value_parent_id = null;
1158
+ // let childSelectedValue = null;
1159
+ // let available_value_array;
1160
+ // // if attribute is child attribute we will find child selected value
1161
+ // if (currentAttribute.parent_id)
1162
+ // {
1163
+ // value_parent_id = -1;
1164
+ // childSelectedValue = Object.values ( this.attributeIdz[ currentAttribute.parent_id ][ 'values' ] ).find ( v => ( v.selected == true && v.applyhidden == false && v.shouldhidden == false ) );
1165
+ // if (childSelectedValue != undefined)
1166
+ // {
1167
+ // value_parent_id = childSelectedValue.id;
1168
+ // }
1169
+ // available_value_array = Object.values ( this.attributeIdz[ c_aid ][ 'values' ] ).filter ( v => ( v.selected == false && v.parent_id == value_parent_id && v.applyhidden == false && v.shouldhidden == false ) );
1170
+ // }else{
1171
+ // available_value_array = Object.values ( this.attributeIdz[ c_aid ][ 'values' ] ).filter ( v => ( v.selected == false && v.applyhidden == false && v.shouldhidden == false ) );
1172
+ // }
1173
+ // //search any value which is not hidden and not selected
1174
+ // // if found select it and return
1175
+ // if ( available_value_array.length > 0 )
1176
+ // {
1177
+ // available_value_array.sort ( ( a, b ) => ( a.sortorder - b.sortorder ) )
1178
+ // pick_first_value = available_value_array[ 0 ];
1179
+ // this.attributeIdz[ c_aid ][ 'values' ][ pick_first_value.id ][ 'selected' ] = true;
1180
+ // this.attributeIdz[ c_aid ][ 'values' ][ pick_first_value.id ][ 'oldselected' ] = false;
1181
+ // if (this.attributeIdz[ pick_first_value.aid ].type == this.TYPES['width'] || this.attributeIdz[ pick_first_value.aid ].type == this.TYPES['subwidth'] || this.attributeIdz[ pick_first_value.aid ].type == this.TYPES['height'] || this.attributeIdz[ pick_first_value.aid ].type == this.TYPES['subheight'] )
1182
+ // {
1183
+ // this.markInputSelected(pick_first_value.aid,pick_first_value.id,pick_first_value.value)
1184
+ // }
1185
+ // else
1186
+ // {
1187
+ // this.markSelected(pick_first_value.aid,pick_first_value.id)
1188
+ // }
1189
+ // this.showAttribute(c_aid);
1190
+ // this.showGroup(gid);
1191
+ // // jQuery ( valueClass + pick_first_value.id ).addClass ( 'selected' );
1192
+ // // jQuery ( valueClass + pick_first_value.id ).prop ( 'checked', true );
1193
+ // // jQuery ( document ).find ( '.CustomAttribute.attrib' + pick_first_value.aid ).val ( pick_first_value.id );
1194
+ // // jQuery ( document ).find ( '.element-item-outputvalue-' + pick_first_value.aid ).html ( pick_first_value.title )
1195
+ // // have we check the attributei hide==1 or not ? before showing the attribute
1196
+ // return;
1197
+ // }
1198
+ // group_attributes = Object.values ( this.attributeIdz ).filter ( a => ( a.gid == gid && a.hide == 0 ) );
1199
+ // // has only one attribute so hide the group
1200
+ // if ( group_attributes.length == 1 ) {
1201
+ // // jQuery ( attributeClass + c_aid ).val ( '' );
1202
+ // this.hideGroup(gid)
1203
+ // return
1204
+ // }
1205
+ // let hide_group = true;
1206
+ // // if has multiple attributes
1207
+ // // find if any selected value is found in any attribute
1208
+ // // if find any selected value so
1209
+ // group_attributes.forEach((attribute, index) => {
1210
+ // let findSelectedValue = Object.values(self.attributeIdz[attribute.id]['values']).find(v => v.selected == true && v.applyhidden == false && v.shouldhidden == false);
1211
+ // if (findSelectedValue !== undefined) {
1212
+ // hide_group = false;
1213
+ // } else {
1214
+ // const element = document.querySelector(self.attributeClass + attribute.id);
1215
+ // if (element) {
1216
+ // element.value = ''; // Equivalent to jQuery's `.val('')`
1217
+ // }
1218
+ // self.hideAttribute(attribute.id);
1219
+ // self.unsetMsg(attribute.id);
1220
+ // }
1221
+ // });
1222
+ // if ( hide_group ) {
1223
+ // // jQuery ( attributeClass + c_aid ).val ( '' );
1224
+ // // jQuery ( groupClass + gid ).hide ().addClass('hide_attribute');
1225
+ // this.hideGroup(gid)
1226
+ // } else {
1227
+ // // jQuery ( attributeClass + c_aid ).val ( '' );
1228
+ // // jQuery ( attributeClass + c_aid ).hide ();
1229
+ // this.hideAttribute(c_aid)
1230
+ // this.unsetMsg(c_aid)
1231
+ // }
1232
+ // },
1233
+ hideAttributeOrGroup(c_aid2) {
1234
+ let findSelected_Value;
1235
+ let attr = this.attributeIdz[c_aid2];
1236
+ let parent_value_id = -1;
1237
+ var available_selected_value;
1238
+ if (attr.parent_id) {
1239
+ parent_value_id = this.findSelectedValue(this.attributeIdz[attr.parent_id]["values"]);
1240
+ if (parent_value_id == void 0) {
1241
+ parent_value_id = -2;
1242
+ } else {
1243
+ parent_value_id = parent_value_id.id;
1244
+ }
1245
+ }
1246
+ findSelected_Value = this.findSelectedValue(attr.values, parent_value_id);
1247
+ if (findSelected_Value != void 0)
1248
+ return;
1249
+ let gid = attr.gid;
1250
+ let available_value_array;
1251
+ available_value_array = this.getAvailableValues(c_aid2, parent_value_id);
1252
+ if (available_value_array.length > 0) {
1253
+ available_value_array.sort((a, b) => a.sortorder - b.sortorder);
1254
+ let pick_first_value = available_value_array[0];
1255
+ this.attributeIdz[c_aid2]["values"][pick_first_value.id]["selected"] = true;
1256
+ this.attributeIdz[c_aid2]["values"][pick_first_value.id]["oldselected"] = false;
1257
+ if (this.attributeIdz[pick_first_value.aid].type == this.TYPES["width"] || this.attributeIdz[pick_first_value.aid].type == this.TYPES["subwidth"] || this.attributeIdz[pick_first_value.aid].type == this.TYPES["height"] || this.attributeIdz[pick_first_value.aid].type == this.TYPES["subheight"]) {
1258
+ this.markInputSelected(pick_first_value.aid, pick_first_value.id, pick_first_value.value);
1259
+ } else {
1260
+ this.markSelected(pick_first_value.aid, pick_first_value.id);
1261
+ }
1262
+ this.showAttribute(c_aid2);
1263
+ this.showGroup(gid);
1264
+ return;
1265
+ }
1266
+ let group_attributes = Object.values(this.attributeIdz).filter((a) => a.gid == gid && a.hide == 0);
1267
+ if (group_attributes.length == 1) {
1268
+ this.hideGroup(gid);
1269
+ return;
1270
+ }
1271
+ let hide_group = true;
1272
+ let self = this;
1273
+ group_attributes.forEach(function(attribute, index) {
1274
+ let parent_value_id2 = -1;
1275
+ if (attribute.parent_id) {
1276
+ parent_value_id2 = self.findSelectedValue(self.attributeIdz[attribute.parent_id]["values"]);
1277
+ if (parent_value_id2 === void 0) {
1278
+ self.hideAttribute(attribute.id);
1279
+ self.unsetMsg(attribute.id);
1280
+ return;
1281
+ } else {
1282
+ parent_value_id2 = parent_value_id2.id;
1283
+ }
1284
+ }
1285
+ const findSelected_Value2 = self.findSelectedValue(self.attributeIdz[attribute.id]["values"], parent_value_id2);
1286
+ if (findSelected_Value2 !== void 0) {
1287
+ hide_group = false;
1288
+ } else {
1289
+ self.hideAttribute(attribute.id);
1290
+ self.unsetMsg(attribute.id);
1291
+ }
1292
+ });
1293
+ if (hide_group) {
1294
+ self.hideGroup(gid);
1295
+ } else {
1296
+ self.hideAttribute(c_aid2);
1297
+ self.unsetMsg(c_aid2);
1298
+ }
1299
+ },
1300
+ unsetMsg(aid) {
1301
+ if (Object.values(this.msgStr).length > 0 && this.msgStr[aid] != void 0) {
1302
+ delete this.msgStr[aid];
1303
+ }
1304
+ if (Object.values(this.pdpsummary).length > 0 && this.pdpsummary[aid] != void 0) {
1305
+ delete this.pdpsummary[aid];
1306
+ }
1307
+ },
1308
+ showValueAttributeOrGroup(c_aid2, v_id2) {
1309
+ let gid = this.attributeIdz[c_aid2].gid;
1310
+ let attr = this.attributeIdz[c_aid2];
1311
+ if (attr.parent_id) {
1312
+ let find_selectedValue = this.findSelectedValue(this.attributeIdz[attr.parent_id]["values"]);
1313
+ if (find_selectedValue == void 0 || find_selectedValue && find_selectedValue.id != this.attributeIdz[c_aid2]["values"][v_id2].parent_id) {
1314
+ this.markUnselected(c_aid2, v_id2);
1315
+ this.hideAttributeOrGroup(c_aid2);
1316
+ let attr_selected_val = this.findSelectedValue(attr.values);
1317
+ if (find_selectedValue == void 0 || attr_selected_val == void 0 || attr_selected_val && attr_selected_val.parent_id != find_selectedValue.id) {
1318
+ this.hideAttribute(c_aid2);
1319
+ this.unsetMsg(c_aid2);
1320
+ }
1321
+ return false;
1322
+ }
1323
+ }
1324
+ this.showValue(c_aid2, v_id2);
1325
+ if (this.attributeIdz[c_aid2].hide == 0) {
1326
+ this.showAttribute(c_aid2);
1327
+ this.showGroup(gid);
1328
+ }
1329
+ return true;
1330
+ },
1331
+ // showValueAttributeOrGroup ( c_aid, v_id )
1332
+ // {
1333
+ // let gid = this.attributeIdz[c_aid].gid;
1334
+ // // check parent child hierarchy
1335
+ // let attr = this.attributeIdz[c_aid];
1336
+ // // has parent
1337
+ // if (attr.parent)
1338
+ // {
1339
+ // if(c_aid==794){
1340
+ // debugger;
1341
+ // }
1342
+ // let find_selectedValue = Object.values ( this.attributeIdz[ attr.parent ][ 'values' ] ).find ( v => ( v.selected == true && v.applyhidden == false && v.shouldhidden == false ) );
1343
+ // if (find_selectedValue == undefined || (find_selectedValue && find_selectedValue.id != this.attributeIdz[ c_aid ]['values'][v_id].parent_id ))
1344
+ // {
1345
+ // this.markUnselected(c_aid,v_id)
1346
+ // this.hideAttributeOrGroup ( c_aid )
1347
+ // this.hideAttribute(c_aid)
1348
+ // this.unsetMsg(c_aid)
1349
+ // return false;
1350
+ // }
1351
+ // }
1352
+ // //show value or remove disabled
1353
+ // // jQuery ( valueClass + v_id ).show ();
1354
+ // this.showValue(c_aid,v_id)
1355
+ // // markSelected(c_aid,v_id)
1356
+ // // if ( == 0)
1357
+ // // return ;
1358
+ // if ( this.attributeIdz[ c_aid ].hide == 0 ) {
1359
+ // // jQuery ( attributeClass + c_aid ).show ().removeClass('hide_attribute');
1360
+ // this.showAttribute(c_aid)
1361
+ // // jQuery ( groupClass + gid ).show ().removeClass('hide_attribute');
1362
+ // this.showGroup(gid)
1363
+ // }
1364
+ // return true;
1365
+ // },
1366
+ selectOneValue(c_aid2) {
1367
+ let attr = this.attributeIdz[c_aid2];
1368
+ let parent_value_id = -1;
1369
+ var available_selected_value;
1370
+ if (attr.parent_id) {
1371
+ parent_value_id = this.findSelectedValue(this.attributeIdz[attr.parent_id]["values"]);
1372
+ if (parent_value_id == void 0) {
1373
+ return;
1374
+ }
1375
+ parent_value_id = parent_value_id.id;
1376
+ }
1377
+ available_selected_value = this.findSelectedValue(attr.values, parent_value_id);
1378
+ if (available_selected_value != void 0) {
1379
+ this.attributeIdz[c_aid2]["values"][available_selected_value.id]["oldselected"] = false;
1380
+ this.setSummery(this.attributeIdz[c_aid2], available_selected_value);
1381
+ if (this.attributeIdz[available_selected_value.aid].type == this.TYPES["width"] || this.attributeIdz[available_selected_value.aid].type == this.TYPES["subwidth"] || this.attributeIdz[available_selected_value.aid].type == this.TYPES["height"] || this.attributeIdz[available_selected_value.aid].type == this.TYPES["subheight"]) {
1382
+ this.markInputSelected(available_selected_value.aid, available_selected_value.id, available_selected_value.value);
1383
+ } else {
1384
+ this.markSelected(available_selected_value.aid, available_selected_value.id);
1385
+ }
1386
+ return;
1387
+ }
1388
+ let available_value_array = this.getAvailableValues(c_aid2, parent_value_id);
1389
+ if (available_value_array.length > 0) {
1390
+ available_value_array = available_value_array.sort((a, b) => a.sortorder - b.sortorder);
1391
+ let pick_first_value = available_value_array[0];
1392
+ this.attributeIdz[c_aid2]["values"][pick_first_value.id]["selected"] = true;
1393
+ this.attributeIdz[c_aid2]["values"][pick_first_value.id]["oldselected"] = false;
1394
+ this.setSummery(this.attributeIdz[c_aid2], pick_first_value);
1395
+ if (this.attributeIdz[pick_first_value.aid].type == this.TYPES["width"] || this.attributeIdz[pick_first_value.aid].type == this.TYPES["subwidth"] || this.attributeIdz[pick_first_value.aid].type == this.TYPES["height"] || this.attributeIdz[pick_first_value.aid].type == this.TYPES["subheight"]) {
1396
+ this.markInputSelected(pick_first_value.aid, pick_first_value.id, pick_first_value.value);
1397
+ } else {
1398
+ this.markSelected(pick_first_value.aid, pick_first_value.id);
1399
+ }
1400
+ }
1401
+ },
1402
+ checkChangeAttributesMsg(c_aid2, msgAttributes, msgValue2, selected_value_hidden, child_Values2, first_call2, available2) {
1403
+ var current_selected_value = Object.values(this.attributeIdz[c_aid2]["values"]).find((v) => v.selected == true && v.shouldhidden == false && v.applyhidden == false);
1404
+ var changed_aid = Object.keys(msgAttributes).find((aid) => aid == selected_value_hidden.aid);
1405
+ if (changed_aid == void 0 && current_selected_value != void 0 && first_call2 == false) {
1406
+ let c_s_aid = current_selected_value.aid;
1407
+ var changed_value = Object.values(msgValue2).find((v) => v.id == selected_value_hidden.id);
1408
+ if (changed_value == void 0 && this.attributeIdz[c_s_aid].hide == 0 && this.attributeIdz[c_s_aid].confirm_popup == true && available2 == 1) {
1409
+ let newMsgStr = "";
1410
+ let nfrom = this.attributeIdz[selected_value_hidden.aid]["values"][selected_value_hidden.id].title;
1411
+ let nto = current_selected_value.title;
1412
+ newMsgStr += this.attributeIdz[c_s_aid].title + ": " + nfrom + " to " + nto + "\n";
1413
+ if (!this.msgStr[selected_value_hidden.aid] != void 0) {
1414
+ this.msgStr[selected_value_hidden.aid] = newMsgStr;
1415
+ let parent_attribute_id = c_aid2;
1416
+ var child_attribute = Object.values(this.attributeIdz).filter((a) => a.parent == parent_attribute_id && a.hide == 0);
1417
+ if (child_attribute.length > 0) {
1418
+ child_attribute.forEach((attribute, index) => {
1419
+ let from_has_child_values = Object.values(attribute["values"]).filter((v) => v.parent_id == selected_value_hidden.id);
1420
+ let to_has_child_values = Object.values(attribute["values"]).filter((v) => v.parent_id == current_selected_value.id);
1421
+ child_Values2[current_selected_value.id] = {
1422
+ v_id: current_selected_value.id,
1423
+ selected: true,
1424
+ confirm_popup: true,
1425
+ show: true,
1426
+ child: to_has_child_values.length
1427
+ };
1428
+ child_Values2[selected_value_hidden.id] = {
1429
+ v_id: selected_value_hidden.id,
1430
+ selected: false,
1431
+ confirm_popup: true,
1432
+ hide: true,
1433
+ child: from_has_child_values.length
1434
+ };
1435
+ });
1436
+ }
1437
+ }
1438
+ }
1439
+ } else {
1440
+ if (current_selected_value != void 0 && Object.values(this.msgStr).length > 0 && this.msgStr[c_aid2] != void 0) {
1441
+ let nto = current_selected_value.title;
1442
+ const startPosition = this.msgStr[c_aid2].lastIndexOf(" to ");
1443
+ let replacementText = " to " + nto + ", \n";
1444
+ this.msgStr[c_aid2] = this.msgStr[c_aid2].slice(0, startPosition) + replacementText;
1445
+ }
1446
+ }
1447
+ return {
1448
+ child_Values: child_Values2
1449
+ };
1450
+ },
1451
+ showbox(popUpMsg) {
1452
+ this.confirmPopup = true;
1453
+ const btnYes = document.querySelector("#ChangeAttributeYes");
1454
+ const btnNo = document.querySelector("#ChangeAttributeNo");
1455
+ return new Promise((resolve, reject) => {
1456
+ let yesHandler = resolve;
1457
+ let noHandler = reject;
1458
+ btnYes.addEventListener("click", yesHandler);
1459
+ btnNo.addEventListener("click", noHandler);
1460
+ }).finally(() => {
1461
+ });
1462
+ },
1463
+ async confirmChange(changed_attribs, hiddenAttributes, aid, paid = "") {
1464
+ let self = this;
1465
+ let popUpMsg = Object.values(self.msgStr).join("");
1466
+ if (popUpMsg == "") {
1467
+ return true;
1468
+ }
1469
+ var confirm_change = "";
1470
+ await this.showbox(popUpMsg).then(() => {
1471
+ this.confirmPopup = false;
1472
+ confirm_change = true;
1473
+ }).catch(() => {
1474
+ confirm_change = false;
1475
+ });
1476
+ if (!confirm_change) {
1477
+ Object.keys(hiddenAttributes).forEach((o_aid) => {
1478
+ let o_values = hiddenAttributes[o_aid];
1479
+ if (changed_attribs[o_aid] == void 0 && self.attributeIdz[o_aid].hide == 0) {
1480
+ Object.keys(o_values).forEach((o_vid) => {
1481
+ let o_value = o_values[o_vid];
1482
+ let f_value = self.attributeIdz[o_aid]["values"][o_value.id];
1483
+ if (f_value !== void 0) {
1484
+ self.attributeIdz[o_value.aid]["values"][o_value.id].applyhidden = o_value.applyhidden;
1485
+ self.attributeIdz[o_value.aid]["values"][o_value.id].shouldhidden = o_value.shouldhidden;
1486
+ self.attributeIdz[o_value.aid]["values"][o_value.id].selected = o_value.selected;
1487
+ if (o_value.selected == false) {
1488
+ self.markUnselected(o_aid, f_value.id);
1489
+ self.hideAttributeOrGroup(o_aid);
1490
+ }
1491
+ }
1492
+ });
1493
+ } else {
1494
+ Object.keys(o_values).forEach((o_vid) => {
1495
+ let o_value = o_values[o_vid];
1496
+ let isselect_value = self.attributeIdz[o_aid]["values"][o_value.id];
1497
+ if (isselect_value !== void 0 && isselect_value.selected == false && o_value.oldselected == false && o_value.applyhidden == true) {
1498
+ self.attributeIdz[o_value.aid]["values"][o_value.id].applyhidden = false;
1499
+ self.attributeIdz[o_value.aid]["values"][o_value.id].shouldhidden = false;
1500
+ if ([self.TYPES["swatch"], self.TYPES["drop-down"], self.TYPES["style"]].includes(self.attributeIdz[o_aid].type)) {
1501
+ self.attributeIdz[o_value.aid]["values"][o_value.id].selected = false;
1502
+ }
1503
+ self.markUnselected(o_aid, isselect_value.id);
1504
+ }
1505
+ });
1506
+ }
1507
+ });
1508
+ Object.keys(changed_attribs).forEach((o_aid) => {
1509
+ let o_values = changed_attribs[o_aid];
1510
+ Object.keys(o_values).forEach((o_vid) => {
1511
+ let o_value = o_values[o_vid];
1512
+ let f_value = self.attributeIdz[o_aid]["values"][o_value.id];
1513
+ if (f_value !== void 0) {
1514
+ if (f_value.applyhidden == true) {
1515
+ self.attributeIdz[o_value.aid]["values"][o_value.id].applyhidden = false;
1516
+ self.attributeIdz[o_value.aid]["values"][o_value.id].shouldhidden = false;
1517
+ self.showValueAttributeOrGroup(o_aid, o_value.id);
1518
+ }
1519
+ if (f_value.oldselected == true) {
1520
+ let selected_value = Object.values(self.attributeIdz[o_aid]["values"]).find((v) => v.selected == true && v.shouldhidden == false && v.applyhidden == false);
1521
+ if (selected_value !== void 0) {
1522
+ if ([self.TYPES["swatch"], self.TYPES["drop-down"], self.TYPES["style"]].includes(self.attributeIdz[o_aid].type)) {
1523
+ self.attributeIdz[o_aid]["values"][selected_value.id].selected = false;
1524
+ self.attributeIdz[o_aid]["values"][selected_value.id].oldselected = true;
1525
+ }
1526
+ self.attributeIdz[o_aid]["values"][selected_value.id].shouldhidden = false;
1527
+ self.attributeIdz[o_aid]["values"][selected_value.id].applyhidden = false;
1528
+ const element = document.querySelector(self.attributeClass + o_aid + ' [data-value="' + selected_value.id + '"]');
1529
+ if (element) {
1530
+ element.removeAttribute("selected");
1531
+ element.checked = false;
1532
+ element.classList.remove("active");
1533
+ }
1534
+ let hidden_attribute = hiddenAttributes[o_aid];
1535
+ let hidden_value;
1536
+ if (hidden_attribute !== void 0) {
1537
+ hidden_value = Object.values(hiddenAttributes[o_aid]).find((v) => v.id == selected_value.id);
1538
+ if (hidden_value !== void 0) {
1539
+ self.attributeIdz[o_aid]["values"][selected_value.id].shouldhidden = hidden_value.shouldhidden;
1540
+ self.attributeIdz[o_aid]["values"][selected_value.id].applyhidden = hidden_value.applyhidden;
1541
+ self.markUnselected(o_aid, selected_value.id);
1542
+ }
1543
+ }
1544
+ }
1545
+ self.attributeIdz[o_value.aid]["values"][o_value.id].selected = true;
1546
+ self.attributeIdz[o_value.aid]["values"][o_value.id].oldselected = false;
1547
+ if ([self.TYPES["width"], self.TYPES["subwidth"], self.TYPES["height"], self.TYPES["subheight"]].includes(self.attributeIdz[o_value.aid].type)) {
1548
+ self.markInputSelected(o_value.aid, o_value.id, o_value.value);
1549
+ } else {
1550
+ self.markSelected(o_value.aid, o_value.id);
1551
+ }
1552
+ }
1553
+ }
1554
+ });
1555
+ });
1556
+ let clicked_vid = Object.values(this.attributeIdz[aid]["values"]).find((v) => v.selected == true && v.shouldhidden == false && v.applyhidden == false);
1557
+ let before_clicked_vid = Object.values(this.attributeIdz[aid]["values"]).find((v) => v.oldselected == true && v.shouldhidden == false && v.applyhidden == false);
1558
+ if (clicked_vid !== void 0) {
1559
+ if ([this.TYPES["swatch"], this.TYPES["drop-down"], this.TYPES["style"]].includes(this.attributeIdz[aid].type)) {
1560
+ this.attributeIdz[aid]["values"][clicked_vid.id].selected = false;
1561
+ this.attributeIdz[aid]["values"][clicked_vid.id].oldselected = true;
1562
+ }
1563
+ this.attributeIdz[aid]["values"][clicked_vid.id].applyhidden = false;
1564
+ this.attributeIdz[aid]["values"][clicked_vid.id].shouldhidden = false;
1565
+ this.unsetSummery(aid);
1566
+ const element = document.querySelector(this.attributeClass + aid + ' [data-value="' + clicked_vid.id + '"]');
1567
+ if (element) {
1568
+ element.removeAttribute("selected");
1569
+ element.checked = false;
1570
+ element.classList.remove("active");
1571
+ }
1572
+ if ([this.TYPES["width"], this.TYPES["subwidth"], this.TYPES["height"], this.TYPES["subheight"]].includes(this.attributeIdz[aid].type)) {
1573
+ this.attributeIdz[aid]["values"][clicked_vid.id]["value"] = parseFloat(clicked_vid.ovalue);
1574
+ document.querySelector(this.attributeClass + aid).value = parseFloat(clicked_vid.ovalue);
1575
+ this.setSummery(this.attributeIdz[aid], clicked_vid);
1576
+ }
1577
+ }
1578
+ if (before_clicked_vid !== void 0) {
1579
+ this.attributeIdz[aid]["values"][before_clicked_vid.id].selected = true;
1580
+ this.attributeIdz[aid]["values"][before_clicked_vid.id].oldselected = false;
1581
+ this.attributeIdz[aid]["values"][before_clicked_vid.id].applyhidden = false;
1582
+ this.attributeIdz[aid]["values"][before_clicked_vid.id].shouldhidden = false;
1583
+ if ([this.TYPES["width"], this.TYPES["subwidth"], this.TYPES["height"], this.TYPES["subheight"]].includes(this.attributeIdz[aid].type)) {
1584
+ this.markInputSelected(aid, before_clicked_vid.id, before_clicked_vid.value);
1585
+ } else {
1586
+ this.markSelected(aid, before_clicked_vid.id);
1587
+ }
1588
+ this.setSummery(this.attributeIdz[aid], before_clicked_vid);
1589
+ }
1590
+ var child_attribute = Object.values(this.attributeIdz).filter((a) => a.parent_id == aid && a.hide == 0);
1591
+ if (child_attribute.length > 0) {
1592
+ Object.keys(child_attribute).forEach(function(key) {
1593
+ let attribute = child_attribute[key] != void 0 ? child_attribute[key] : null;
1594
+ if (attribute == null) {
1595
+ return;
1596
+ }
1597
+ var hide_child_values = Object.values(attribute["values"]).filter((v) => v.parent_id == clicked_vid.id);
1598
+ if (hide_child_values.length > 0) {
1599
+ self.hideChildValuesOfParentValue(attribute.id, attribute.parent_id, clicked_vid.id);
1600
+ }
1601
+ var show_child_values = Object.values(attribute["values"]).filter((v) => v.parent_id == before_clicked_vid.id && v.shouldhidden == false && v.applyhidden == false);
1602
+ if (show_child_values.length > 0) {
1603
+ self.showChildValues(attribute.id, before_clicked_vid.id);
1604
+ self.showAttribute(attribute.id);
1605
+ var old_selected_value = Object.values(show_child_values).find((v) => v.oldselected == true);
1606
+ if (old_selected_value == void 0) {
1607
+ show_child_values.sort((a, b) => a.sortorder - b.sortorder);
1608
+ old_selected_value = show_child_values[0];
1609
+ }
1610
+ self.attributeIdz[attribute.id]["values"][old_selected_value.id]["selected"] = true;
1611
+ self.attributeIdz[attribute.id]["values"][old_selected_value.id]["oldselected"] = false;
1612
+ if (self.attributeIdz[old_selected_value.aid].type == self.TYPES["width"] || self.attributeIdz[old_selected_value.aid].type == self.TYPES["subwidth"] || self.attributeIdz[old_selected_value.aid].type == self.TYPES["height"] || self.attributeIdz[old_selected_value.aid].type == self.TYPES["subheight"]) {
1613
+ self.markInputSelected(old_selected_value.aid, old_selected_value.id, old_selected_value.value);
1614
+ } else {
1615
+ self.markSelected(old_selected_value.aid, old_selected_value.id);
1616
+ }
1617
+ } else {
1618
+ self.hideAttribute(attribute.id);
1619
+ }
1620
+ if (paid !== void 0 && paid !== "") {
1621
+ let clicked_pvid = Object.values(this.attributeIdz[paid]["values"]).find((v) => v.selected == true && v.shouldhidden == false && v.applyhidden == false);
1622
+ let before_clicked_pvid = Object.values(this.attributeIdz[paid]["values"]).find((v) => v.oldselected == true && v.shouldhidden == false && v.applyhidden == false);
1623
+ if (clicked_pvid !== void 0) {
1624
+ if ([this.TYPES["swatch"], this.TYPES["drop-down"], this.TYPES["style"]].includes(this.attributeIdz[aid].type)) {
1625
+ this.attributeIdz[aid]["values"][clicked_pvid.id].selected = false;
1626
+ this.attributeIdz[aid]["values"][clicked_pvid.id].oldselected = true;
1627
+ }
1628
+ this.attributeIdz[aid]["values"][clicked_pvid.id].applyhidden = false;
1629
+ this.attributeIdz[aid]["values"][clicked_pvid.id].shouldhidden = false;
1630
+ const element = document.querySelector(this.attributeClass + aid + ' [data-value="' + clicked_pvid.id + '"]');
1631
+ if (element) {
1632
+ element.removeAttribute("selected");
1633
+ element.checked = false;
1634
+ element.classList.remove("active");
1635
+ }
1636
+ }
1637
+ if (before_clicked_pvid !== void 0) {
1638
+ this.attributeIdz[aid]["values"][before_clicked_pvid.id].selected = true;
1639
+ this.attributeIdz[aid]["values"][before_clicked_pvid.id].oldselected = false;
1640
+ this.attributeIdz[aid]["values"][before_clicked_pvid.id].applyhidden = false;
1641
+ this.attributeIdz[aid]["values"][before_clicked_pvid.id].shouldhidden = false;
1642
+ if ([this.TYPES["width"], this.TYPES["subwidth"], this.TYPES["height"], this.TYPES["subheight"]].includes(this.attributeIdz[aid].type)) {
1643
+ this.markInputSelected(aid, before_clicked_pvid.id, before_clicked_pvid.value);
1644
+ } else {
1645
+ this.markSelected(aid, before_clicked_pvid.id);
1646
+ }
1647
+ }
1648
+ }
1649
+ self.processAttributes();
1650
+ self.calculatePrice();
1651
+ return false;
1652
+ });
1653
+ }
1654
+ this.confirmPopup = false;
1655
+ return false;
1656
+ }
1657
+ return true;
1658
+ },
1659
+ customRoundUp(value) {
1660
+ if (typeof value !== "number" || isNaN(value)) {
1661
+ return 0;
1662
+ }
1663
+ let scaledValue = value * 1e3;
1664
+ let roundedValue = Math.ceil(scaledValue);
1665
+ return Math.round(roundedValue / 10) / 100;
1666
+ },
1667
+ sqrunitprice(price, width, height, unit_relative) {
1668
+ var unitSqr = 0;
1669
+ var unit_relative = unit_relative == void 0 || unit_relative == 0 || unit_relative == "" || unit_relative == null ? 1 : unit_relative;
1670
+ let widthSqr = parseFloat(width) / unit_relative;
1671
+ let heightSqr = parseFloat(height) / unit_relative;
1672
+ unitSqr = parseFloat(widthSqr) * parseFloat(heightSqr);
1673
+ unitSqr = this.customRoundUp(unitSqr);
1674
+ return parseFloat(unitSqr) * parseFloat(price);
1675
+ },
1676
+ sqrmeasureprice(price, measurement, unit_relative) {
1677
+ var unitSqr = 0;
1678
+ var unit_relative = unit_relative == void 0 || unit_relative == 0 || unit_relative == "" || unit_relative == null ? 1 : unit_relative;
1679
+ unitSqr = parseFloat(measurement) / unit_relative;
1680
+ unitSqr = this.customRoundUp(unitSqr);
1681
+ return parseFloat(unitSqr) * parseFloat(price);
1682
+ },
1683
+ closest(num, arr) {
1684
+ var mid;
1685
+ var lo = 0;
1686
+ var hi = arr.length - 1;
1687
+ while (hi - lo > 1) {
1688
+ mid = Math.floor((lo + hi) / 2);
1689
+ if (arr[mid] < num) {
1690
+ lo = mid;
1691
+ } else {
1692
+ hi = mid;
1693
+ }
1694
+ }
1695
+ if (lo == 0 && hi == 1) {
1696
+ if (num <= arr[lo]) {
1697
+ return arr[lo];
1698
+ }
1699
+ return arr[hi];
1700
+ }
1701
+ return arr[hi];
1702
+ },
1703
+ lookupprice(price, width = null, height = null) {
1704
+ if (typeof price == null) {
1705
+ return 0;
1706
+ }
1707
+ if (price == void 0) {
1708
+ return 0;
1709
+ }
1710
+ if (width == null && height == null) {
1711
+ return price;
1712
+ }
1713
+ let dropz = Object.keys(price);
1714
+ dropz = dropz.map(Number);
1715
+ dropz = dropz.sort((a, b) => a - b);
1716
+ let drop = dropz.indexOf(height);
1717
+ if (drop == -1) {
1718
+ height = this.closest(height, dropz);
1719
+ } else {
1720
+ height = dropz[drop];
1721
+ }
1722
+ let fabprice = price[height];
1723
+ if (fabprice == void 0) {
1724
+ return 0;
1725
+ }
1726
+ let widthz = Object.keys(fabprice);
1727
+ widthz = widthz.map(Number);
1728
+ widthz = widthz.sort((a, b) => a - b);
1729
+ let widthindex = widthz.indexOf(width);
1730
+ if (widthindex == -1) {
1731
+ width = this.closest(width, widthz);
1732
+ } else {
1733
+ width = widthz[widthindex];
1734
+ }
1735
+ return parseFloat(fabprice[width]);
1736
+ },
1737
+ swatchimage() {
1738
+ this.overlayimages = [];
1739
+ let findstyleswatch = Object.values(this.attributeIdz).filter((a) => (a.type == this.TYPES["style"] || a.type == this.TYPES["swatch"]) && a.generate_swatches);
1740
+ if (findstyleswatch.length) {
1741
+ findstyleswatch = findstyleswatch.sort((a, b) => a.gsortorder - b.gsortorder || a.sortorder - b.sortorder);
1742
+ findstyleswatch.forEach((attribute) => {
1743
+ const value = Object.values(attribute["values"]).find((v) => v.selected == true && v.shouldhidden == false && v.applyhidden == false && v.overlay_image !== "");
1744
+ if (value !== void 0) {
1745
+ this.overlayimages.push(value.overlay_image);
1746
+ }
1747
+ });
1748
+ }
1749
+ },
1750
+ getMeasurement(attribute_type) {
1751
+ let value = 0;
1752
+ let findvalue = Object.values(this.attributeIdz).find((a) => a.type == attribute_type);
1753
+ if (findvalue != void 0) {
1754
+ let vid = Object.keys(this.attributeIdz[findvalue.id]["values"]);
1755
+ if (vid != void 0) {
1756
+ value = this.attributeIdz[findvalue.id]["values"][vid].value;
1757
+ }
1758
+ }
1759
+ if (value == void 0 || isNaN(value) || value == "" || value < 0) {
1760
+ value = 0;
1761
+ }
1762
+ value = parseFloat(value);
1763
+ return value;
1764
+ },
1765
+ getMeasurementByID(attribute_id) {
1766
+ let value = 0;
1767
+ let findvalue = Object.values(this.attributeIdz).find((a) => a.id == attribute_id);
1768
+ if (findvalue != void 0) {
1769
+ let vid = Object.keys(this.attributeIdz[findvalue.id]["values"]);
1770
+ if (vid != void 0) {
1771
+ value = this.attributeIdz[findvalue.id]["values"][vid].value;
1772
+ }
1773
+ }
1774
+ if (value == void 0 || isNaN(value) || value == "" || value < 0) {
1775
+ value = 0;
1776
+ }
1777
+ value = parseFloat(value);
1778
+ return value;
1779
+ },
1780
+ getSubHeights() {
1781
+ return Object.values(this.attributeIdz).filter((a) => a.type == this.TYPES["subheight"] && a.linkto !== null);
1782
+ },
1783
+ getSubWidths() {
1784
+ return Object.values(this.attributeIdz).filter((a) => a.type == this.TYPES["subwidth"] && a.linkto !== null);
1785
+ },
1786
+ calculateMultiPrice(width, height, value, subWidths, subHeights) {
1787
+ let total = 0;
1788
+ let sub_height = 0;
1789
+ let sub_width = 0;
1790
+ if (subWidths.length != 0) {
1791
+ for (let index = 0; index < subWidths.length; index++) {
1792
+ sub_height = sub_width = 0;
1793
+ sub_width = this.getMeasurementByID(subWidths[index].id);
1794
+ if (!sub_width || sub_width <= 0) {
1795
+ continue;
1796
+ }
1797
+ if (subWidths[index].linktotype == this.TYPES["height"]) {
1798
+ sub_height = height;
1799
+ } else if (subWidths[index].linktotype == this.TYPES["subheight"]) {
1800
+ sub_height = this.getMeasurementByID(subWidths[index].linkto);
1801
+ }
1802
+ if (value.price_type == this.PRICETYPE["grouppricing"]) {
1803
+ var value_price = this.getValuePrice(value.group_pricing_type, sub_width, sub_height, this.PRICETYPE, value.group_price, this.lookupprices[value.id]);
1804
+ } else {
1805
+ var value_price = this.getValuePrice(value.price_type, sub_width, sub_height, this.PRICETYPE, value.price, this.lookupprices[value.id]);
1806
+ }
1807
+ this.getValuePriceDiscount(value.discount_type, value.discount, value_price);
1808
+ total = parseFloat(total) + value_price;
1809
+ }
1810
+ } else {
1811
+ for (let index = 0; index < subHeights.length; index++) {
1812
+ sub_width = 0;
1813
+ sub_height = this.getMeasurementByID(subHeights[index].id);
1814
+ if (!sub_height || sub_height <= 0) {
1815
+ continue;
1816
+ }
1817
+ if (subHeights[index].linktotype == this.TYPES["width"]) {
1818
+ sub_width = width;
1819
+ } else if (subHeights[index].linktotype == this.TYPES["subwidth"]) {
1820
+ sub_width = this.getMeasurementByID(subHeights[index].linkto);
1821
+ }
1822
+ if (value.price_type == this.PRICETYPE["grouppricing"]) {
1823
+ var value_price = this.getValuePrice(value.group_pricing_type, sub_width, sub_height, this.PRICETYPE, value.group_price, this.lookupprices[value.id]);
1824
+ } else {
1825
+ var value_price = this.getValuePrice(value.price_type, sub_width, sub_height, this.PRICETYPE, value.price, this.lookupprices[value.id]);
1826
+ }
1827
+ this.getValuePriceDiscount(value.discount_type, value.discount, value_price);
1828
+ total = parseFloat(total) + value_price;
1829
+ }
1830
+ }
1831
+ return total;
1832
+ },
1833
+ getValuePrice(price_type, width, height, PRICE_TYPES, price, priceArray) {
1834
+ if (price_type == PRICE_TYPES["unit-price"]) {
1835
+ return parseFloat(price);
1836
+ } else if (price_type == PRICE_TYPES["grid"] || price_type == PRICE_TYPES["grouppricing"]) {
1837
+ return parseFloat(this.lookupprice(priceArray, width, height));
1838
+ } else if (price_type == PRICE_TYPES["widthlookup"] && width > 0) {
1839
+ return parseFloat(this.lookupprice(priceArray, width, height));
1840
+ } else if (price_type == PRICE_TYPES["heightlookup"] && height > 0) {
1841
+ return parseFloat(this.lookupprice(priceArray, width, height));
1842
+ } else if (price_type == PRICE_TYPES["sqr-meter"]) {
1843
+ return parseFloat(this.sqrunitprice(price, width, height, this.UNIT_RELATIVE[PRICE_TYPES["sqr-meter"]]));
1844
+ } else if (price_type == PRICE_TYPES["sqr-feet"]) {
1845
+ return parseFloat(this.sqrunitprice(price, width, height, this.UNIT_RELATIVE[PRICE_TYPES["sqr-feet"]]));
1846
+ } else if (price_type == PRICE_TYPES["widthfeet"] && width > 0) {
1847
+ return parseFloat(this.sqrunitprice(price, width, height, this.UNIT_RELATIVE[PRICE_TYPES["widthfeet"]]));
1848
+ } else if (price_type == PRICE_TYPES["heightfeet"] && height > 0) {
1849
+ return parseFloat(this.sqrunitprice(price, width, height, this.UNIT_RELATIVE[PRICE_TYPES["heightfeet"]]));
1850
+ } else if (price_type == PRICE_TYPES["width"] && width > 0) {
1851
+ return parseFloat(this.sqrmeasureprice(price, width, this.UNIT_RELATIVE[PRICE_TYPES["width"]]));
1852
+ } else if (price_type == PRICE_TYPES["height"] && height > 0) {
1853
+ return parseFloat(this.sqrmeasureprice(price, height, this.UNIT_RELATIVE[PRICE_TYPES["height"]]));
1854
+ }
1855
+ return parseFloat(0);
1856
+ },
1857
+ getValuePriceDiscount(discount_type, discount, value_price) {
1858
+ if (discount_type == 2 && discount > 0) {
1859
+ if (parseFloat(discount) > parseFloat(value_price)) {
1860
+ discount = value_price;
1861
+ }
1862
+ this.total_values_discount = parseFloat(this.total_values_discount) + parseFloat(discount);
1863
+ } else if (discount_type == 1 && discount > 0) {
1864
+ this.total_values_discount = parseFloat(this.total_values_discount) + parseFloat(value_price) * parseFloat(discount) / 100;
1865
+ }
1866
+ },
1867
+ setValuePricePromotionsDiscount(attributes) {
1868
+ attributes = Object.values(attributes).filter((a) => a.link_promotion == 1);
1869
+ for (var index in attributes) {
1870
+ var value = Object.values(attributes[index]["values"]).find((v) => v.sku_product_id != null && v.selected == true && v.applyhidden == false && v.shouldhidden == false && (v.price_type != "0" && v.price_type != null && v.price_type != ""));
1871
+ if (value != void 0) {
1872
+ var promotions = this.linked_promotionSettings[value.sku_product_id];
1873
+ if (promotions != void 0) {
1874
+ for (var p_index in promotions) {
1875
+ var promotion = promotions[p_index];
1876
+ for (var exc_index in promotion["excludes"]) {
1877
+ if (!this.promotion_excludes.includes(promotion["excludes"][exc_index])) {
1878
+ this.promotion_excludes.push(promotion["excludes"][exc_index]);
1879
+ }
1880
+ }
1881
+ }
1882
+ }
1883
+ }
1884
+ }
1885
+ },
1886
+ getValuePricePromotionDiscount(product_id, value_price) {
1887
+ var fix_discount = 0;
1888
+ var percentage_discount = 0;
1889
+ var promotions = this.linked_promotionSettings[product_id];
1890
+ if (promotions != void 0) {
1891
+ for (var p_index in promotions) {
1892
+ var promotion = promotions[p_index];
1893
+ if (!this.promotion_excludes.includes(promotion["id"])) {
1894
+ if (promotion["voucherdiscounttype_id"] == 2) {
1895
+ percentage_discount = percentage_discount + promotion["discount"];
1896
+ } else if (promotion["voucherdiscounttype_id"] == 3) {
1897
+ fix_discount = fix_discount + promotion["discount"];
1898
+ }
1899
+ }
1900
+ }
1901
+ }
1902
+ if (fix_discount > 0) {
1903
+ this.getValuePriceDiscount(2, fix_discount, value_price);
1904
+ }
1905
+ if (percentage_discount > 0) {
1906
+ this.getValuePriceDiscount(1, percentage_discount, value_price);
1907
+ }
1908
+ },
1909
+ calculatePrice() {
1910
+ let width = this.getMeasurement(this.TYPES["width"]);
1911
+ let height = this.getMeasurement(this.TYPES["height"]);
1912
+ let value_price = 0;
1913
+ let calculate_MultiPrice = false;
1914
+ let subWidths = this.getSubWidths();
1915
+ let subHeights = this.getSubHeights();
1916
+ let noOfSubWidths = subWidths.length;
1917
+ let noOfSubdrops = subHeights.length;
1918
+ if (noOfSubdrops != 0 || noOfSubWidths != 0) {
1919
+ calculate_MultiPrice = true;
1920
+ }
1921
+ let actual_price = parseFloat(this.BASEPRICE);
1922
+ let total = 0;
1923
+ let attributes = Object.values(this.attributeIdz).filter((a) => a.price_applicable == true);
1924
+ this.setValuePricePromotionsDiscount(attributes);
1925
+ for (var index in attributes) {
1926
+ var value = Object.values(attributes[index]["values"]).find((v) => v.selected == true && v.applyhidden == false && v.shouldhidden == false && (v.price_type != "0" && v.price_type != null && v.price_type != ""));
1927
+ if (value != void 0) {
1928
+ if (attributes[index].parent_id) {
1929
+ let find_selectedValue = Object.values(this.attributeIdz[attributes[index].parent_id]["values"]).find((v) => v.selected == true && v.applyhidden == false && v.shouldhidden == false);
1930
+ if (find_selectedValue == void 0 || find_selectedValue && find_selectedValue.id != attributes[index]["values"][value.id].parent_id) {
1931
+ continue;
1932
+ }
1933
+ }
1934
+ if (value.price_type == this.PRICETYPE["custom"]) {
1935
+ this.price_by_attributeobject = [];
1936
+ this.price_by_attributeobject["attribute"] = attributes[index];
1937
+ this.price_by_attributeobject["price_attribute"] = value.price_attribute;
1938
+ this.price_by_attributeobject["value"] = value;
1939
+ this.price_by_attributes.push(this.price_by_attributeobject);
1940
+ continue;
1941
+ }
1942
+ if (attributes[index].multiprice == true && calculate_MultiPrice == true) {
1943
+ value_price = this.calculateMultiPrice(width, height, value, subWidths, subHeights);
1944
+ this.findprice = Object.values(this.attributeprices).find((ap) => ap["attribute"].id == attributes[index].id);
1945
+ if (!this.findprice) {
1946
+ this.attributepriceobject = [];
1947
+ this.attributepriceobject["attribute"] = attributes[index];
1948
+ this.attributepriceobject["value"] = value;
1949
+ this.attributepriceobject["price"] = value_price;
1950
+ this.attributeprices.push(this.attributepriceobject);
1951
+ }
1952
+ total = parseFloat(total) + value_price;
1953
+ } else {
1954
+ if (value.price_type == this.PRICETYPE["grouppricing"]) {
1955
+ value_price = this.getValuePrice(value.group_pricing_type, width, height, this.PRICETYPE, value.group_price, this.lookupprices[value.id]);
1956
+ } else {
1957
+ value_price = this.getValuePrice(value.price_type, width, height, this.PRICETYPE, value.price, this.lookupprices[value.id]);
1958
+ }
1959
+ if (attributes[index].link_promotion == 1 && value.sku_product_id != null) {
1960
+ this.getValuePricePromotionDiscount(value.sku_product_id, value_price);
1961
+ } else {
1962
+ this.getValuePriceDiscount(value.discount_type, value.discount, value_price);
1963
+ }
1964
+ this.findprice = Object.values(this.attributeprices).find((ap) => ap["attribute"].id == attributes[index].id);
1965
+ if (!this.findprice) {
1966
+ this.attributepriceobject = [];
1967
+ this.attributepriceobject["attribute"] = attributes[index];
1968
+ this.attributepriceobject["value"] = value;
1969
+ this.attributepriceobject["price"] = value_price;
1970
+ this.attributeprices.push(this.attributepriceobject);
1971
+ }
1972
+ total = parseFloat(total) + value_price;
1973
+ }
1974
+ if (attributes[index].exclude_product_promotion == 1) {
1975
+ this.exclude_from_promo_total = parseFloat(this.exclude_from_promo_total) + value_price;
1976
+ }
1977
+ }
1978
+ }
1979
+ for (const price_by_attribute of this.price_by_attributes) {
1980
+ this.findprice = Object.values(this.attributeprices).find((ap) => ap["attribute"].id == price_by_attribute.price_attribute && ap["price"] > 0);
1981
+ if (this.findprice) {
1982
+ let value_price2 = parseFloat(this.findprice["price"]) * (price_by_attribute["value"].price / 100);
1983
+ if (price_by_attribute["attribute"].link_promotion == 1 && price_by_attribute["value"].sku_product_id != null) {
1984
+ this.getValuePricePromotionDiscount(price_by_attribute["value"].sku_product_id, value_price2);
1985
+ } else {
1986
+ this.getValuePriceDiscount(price_by_attribute["value"].discount_type, price_by_attribute["value"].discount, value_price2);
1987
+ }
1988
+ total = parseFloat(total) + value_price2;
1989
+ if (price_by_attribute["attribute"].exclude_product_promotion == 1) {
1990
+ this.exclude_from_promo_total = parseFloat(this.exclude_from_promo_total) + value_price2;
1991
+ }
1992
+ }
1993
+ }
1994
+ if (this.USEBASEPRICE && parseFloat(total) < parseFloat(this.BASEPRICE)) {
1995
+ total = parseFloat(this.BASEPRICE);
1996
+ }
1997
+ actual_price = total;
1998
+ let rrprice = 0;
1999
+ let discount = 0;
2000
+ if (Object.values(this.DISCOUNTS).length) {
2001
+ discount = this.DISCOUNTS[this.B2BTYPE] != void 0 ? this.DISCOUNTS[this.B2BTYPE] : 0;
2002
+ discount = parseFloat(total) * parseFloat(discount) / 100;
2003
+ }
2004
+ let promotionDiscount = discount + parseFloat(this.total_values_discount);
2005
+ if (this.promotionSettings != void 0 && this.promotionSettings.promotion != void 0 && this.promotionSettings.promotion == true) {
2006
+ if (this.promotionSettings.promotiontype == 3) {
2007
+ for (var i = this.promotionSettings.rules.length - 1; i >= 0; i--) {
2008
+ let rule = this.promotionSettings.rules[i];
2009
+ if (rule.discounttype != void 0 || rule.discount != void 0) {
2010
+ let new_total = parseFloat(total) - parseFloat(this.exclude_from_promo_total);
2011
+ promotionDiscount += this.calculateDiscount(rule.discounttype, rule.discount, new_total);
2012
+ }
2013
+ }
2014
+ }
2015
+ }
2016
+ if (parseFloat(total) - parseFloat(promotionDiscount) > 0 && promotionDiscount > 0) {
2017
+ promotionDiscount = this.customRoundUp(promotionDiscount);
2018
+ total = parseFloat(total) - parseFloat(promotionDiscount);
2019
+ }
2020
+ if (parseFloat(actual_price) > parseFloat(total)) {
2021
+ this.productDiscountedPrice = actual_price.toFixed(2);
2022
+ } else {
2023
+ this.productDiscountedPrice = 0;
2024
+ }
2025
+ if (document.querySelector(this.priceClass)) {
2026
+ document.querySelector(this.priceClass).innerHTML = total.toFixed(2);
2027
+ }
2028
+ this.productPrice = total.toFixed(2);
2029
+ },
2030
+ calculateDiscount(discounttype, discount, price) {
2031
+ if (discounttype == 2) {
2032
+ discount = parseFloat(price) * parseFloat(discount / 100);
2033
+ if (price - discount < 0)
2034
+ return 0;
2035
+ return parseFloat(discount);
2036
+ } else if (discounttype == 3) {
2037
+ if (price - discount < 0)
2038
+ return price;
2039
+ return parseFloat(discount);
2040
+ }
2041
+ return 0;
2042
+ },
2043
+ calculateservicePrice() {
2044
+ const self = this;
2045
+ if (typeof this.servicePriceSetting == "undefined") {
2046
+ this.serviceprice = 0;
2047
+ return;
2048
+ }
2049
+ let width = this.getMeasurement(this.TYPES["width"]);
2050
+ let height = this.getMeasurement(this.TYPES["height"]);
2051
+ if (height == void 0 || isNaN(height) || height == "" || height < 0) {
2052
+ height = 0;
2053
+ }
2054
+ if (width == void 0 || isNaN(width) || width == "" || width < 0) {
2055
+ width = 0;
2056
+ }
2057
+ let total = 0;
2058
+ if (this.sevice_price_type == this.servicePriceSetting["types"]["custom"]) {
2059
+ Object.keys(this.servicePriceSetting["pricelist"]).forEach((aid) => {
2060
+ let values = self.servicePriceSetting["pricelist"][aid];
2061
+ let selected_val2 = Object.values(self.attributeIdz[aid]["values"]).find((v) => v.selected == true);
2062
+ if (selected_val2 !== void 0 && values[selected_val2.id] !== void 0) {
2063
+ total += parseFloat(values[selected_val2.id]);
2064
+ }
2065
+ });
2066
+ } else {
2067
+ total += this.getValuePrice(
2068
+ this.sevice_price_type,
2069
+ width,
2070
+ height,
2071
+ this.servicePriceSetting["types"],
2072
+ this.servicePriceSetting["serviceprice"],
2073
+ this.servicePriceSetting["pricelist"]
2074
+ );
2075
+ }
2076
+ this.serviceprice = total;
2077
+ }
2078
+ }
2079
+ });