e_plat 1.1.0.pre.rc.5 → 1.1.0.pre.rc.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2206781bbf8868908c0e96fe7c14598796565160e8dda1552dcb039f15dc42de
4
- data.tar.gz: '08d8237e1f2117e6b2d732b22450f770ff19525701b150e734021119332adeea'
3
+ metadata.gz: 833b26a5921eefe442db62b9fe641e6f5e46867f8cc0f48ceb2408445620d336
4
+ data.tar.gz: 52d27808a6b87c2cd0cb665ee2cf8f69762a016e049fedee6e7be6f6d173734a
5
5
  SHA512:
6
- metadata.gz: 16d8aef337c863094e137d709a9180fb313570de1df5b8a80083b448a98846bac6afe0b762fdf7a7f79e4c05dc3666eaf91bc7cafd26db4991eb5fccd2a3b265
7
- data.tar.gz: 898f2f7cbd29a897dce7d790800a20523d13579955f548471e1482ec78588c002b373b52b90606ccbde113a85aca792ac7e76d238d8e8d49510488feb1e6cebd
6
+ metadata.gz: '09ce505d88e5606f687c36df5eb7598410dff69a5c414ca294bf518d8538c14dd38e0fac49f3982c1ca707e89a84dca05e4275549ae247c8166188bc966bc7c8'
7
+ data.tar.gz: d9e38fd5731e7dfac6dc723acf5946832017cbc3ab14f8835dcbbd83e5bbcaa69435550e62e0446ec33c16030727347b8a4a8a6e924cd3b7419641941eea5816
data/README.md CHANGED
@@ -331,7 +331,7 @@ helper methods: <br>
331
331
 
332
332
  | Alias | Type | Shopify | BigCommerce | WooCommerce |
333
333
  |----------|----------|---------|------------------------------|-----------------------------------|
334
- | id | integer | * | id | attributes[i][id] |
334
+ | id | integer | * | id | ID derived from name |
335
335
  | name | string | * | display_name | attributes[i][name] |
336
336
  | position | integer | * | sort_order | attributes[i][position] |
337
337
  | values | array | * | option_values[i][label] | attributes[i][options] |
@@ -355,7 +355,7 @@ helper methods: <br>
355
355
 
356
356
  | Alias | Type | Shopify | BigCommerce | WooCommerce |
357
357
  |-------|----------|------------------------------------------|---------------------|----------------------------------------------|
358
- | id | integer | [selected_options][option_value][id] | id | attributes[i][id] |
358
+ | id | integer | [selected_options][option_value][id] | id | ID derived from name |
359
359
  | name | string | [selected_options][name] | option_display_name | attributes[i][name] |
360
360
  | value | string | [selected_options][value] | label | attributes[i][option] |
361
361
 
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  module EPlat
4
2
  class Base < ActiveResource::Base
5
3
  include Concerns::OverwriteRequestMethods, Concerns::OverwriteInstanceMethods
@@ -168,6 +166,23 @@ module EPlat
168
166
  raise EPlat::Error.new("GraphQL input not supported for this resource and platform")
169
167
  end
170
168
 
169
+ # Generate a consistent integer ID from a string
170
+ # This method will always return the same ID for the same string
171
+ def string_to_consistent_id(str)
172
+ # Normalize the string (lowercase, remove spaces)
173
+ normalized = str.to_s.downcase.gsub(/\s+/, '')
174
+
175
+ # Use a consistent algorithm to convert string to integer
176
+ # Simple sum of ASCII values multiplied by position
177
+ id = 0
178
+ normalized.each_char.with_index do |char, index|
179
+ id += (char.ord * (index + 1))
180
+ end
181
+
182
+ # Keep it within a reasonable range (1-1,000,000)
183
+ (id % 1_000_000) + 1
184
+ end
185
+
171
186
  private
172
187
 
173
188
  def ensure_e_plat_attributes!
@@ -16,6 +16,20 @@ module EPlat::Woocommerce
16
16
  instance
17
17
  end
18
18
  end
19
+
20
+ def initialize(attributes = {}, persisted = false)
21
+ super
22
+
23
+ # Ensure option_values have stable IDs based on name
24
+ if self.option_values.present?
25
+ self.option_values.each do |option_value|
26
+ if (option_value.attributes["id"].nil? || option_value.attributes["id"] == 0) && option_value.name.present?
27
+ # Use the same deterministic ID generation method as product options
28
+ option_value.attributes["id"] = string_to_consistent_id(option_value.name)
29
+ end
30
+ end
31
+ end
32
+ end
19
33
 
20
34
  def save
21
35
  if _is_virtual
@@ -2,6 +2,20 @@ module EPlat::Woocommerce
2
2
  class Product < EPlat::Product
3
3
  has_many :meta_data, class_name: "EPlat::Woocommerce::Metafield"
4
4
 
5
+ def initialize(attributes = {}, persisted = false)
6
+ super
7
+
8
+ # Ensure options have correct IDs based on name (more stable than position)
9
+ if self.options.present?
10
+ self.options.each do |option|
11
+ if (option.attributes["id"].nil? || option.attributes["id"] == 0) && option.name.present?
12
+ # Use a deterministic ID generation method
13
+ option.attributes["id"] = string_to_consistent_id(option.name)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
5
19
  def lazy_load_variants
6
20
  # Woo products natively just return an array of ids under the 'variations' key
7
21
  @variants_collection ||= EPlat::Product::Variant.find(
@@ -24,7 +38,6 @@ module EPlat::Woocommerce
24
38
  end
25
39
  end
26
40
 
27
-
28
41
  def common_product_variant_attributes
29
42
  [
30
43
  "body_html",
@@ -1,3 +1,3 @@
1
1
  module EPlat
2
- VERSION = "1.1.0-rc.5"
2
+ VERSION = "1.1.0-rc.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e_plat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.pre.rc.5
4
+ version: 1.1.0.pre.rc.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - oliwoodsuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-21 00:00:00.000000000 Z
11
+ date: 2025-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler