e_plat 1.1.0.pre.rc.6 → 1.1.0.pre.rc.8

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: ae49d0be03b307f8982ec8ab83f200cf1a5b22159b7454ae3dee0e50a4fe4dde
4
- data.tar.gz: 94acc2fcd262d76ad8ac02dfb355b330297472ec6d4b8355b2ce27bc18758ed3
3
+ metadata.gz: 46fbc594c104c4beedff0ba465d323dee4dc3dec07487506d697f74b2f5cf93c
4
+ data.tar.gz: e76bfe7bc0033f416833c720d759467dc02fb16e49b69c10c092e19f23ef9f63
5
5
  SHA512:
6
- metadata.gz: 40de991243c9611dc785ac2336043d211db3b0a35b5d2c87df2b457092d5601e84862e85980b0d2c8b42a21ed6267a57ca5b6c182e89c368817a982adb5ed707
7
- data.tar.gz: 3ab713d5bca7758ae7c0c44abc2cea97fcdb85f696b381028d4d358a50bc702acc28e82a638bdd549b4568884e919970b11063784337383033c93e6e5ab70ba7
6
+ metadata.gz: af5a27b232c51e295b8e7fa4ff1b7ddaa29b5671e412ca3847a851c28b347b9ed1807d323419619185b6ae42a030a442525d927f71da3cd8027faef9e79f9620
7
+ data.tar.gz: 6a3f66b61023373ec10546ad49ab452c349afca9e58034d0625299d3620f94605ba3c591d6db0ade2468a4f7fc35139db7562634167919c94733851e18eb2418
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 | name.downcase.hash.abs % 1000000 |
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 | name.downcase.hash.abs % 1000000 |
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!
@@ -20,13 +20,14 @@ module EPlat::Woocommerce
20
20
  def initialize(attributes = {}, persisted = false)
21
21
  super
22
22
 
23
- # Ensure option_values have stable IDs based on name
23
+ # Ensure option_values have stable IDs based on name and option value combined
24
24
  if self.option_values.present?
25
25
  self.option_values.each do |option_value|
26
26
  if (option_value.attributes["id"].nil? || option_value.attributes["id"] == 0) && option_value.name.present?
27
- # Use the hash of the name (lowercase) as a consistent ID
28
- # We're using the name here because it refers to the attribute name (like "Color", "Size")
29
- option_value.attributes["id"] = option_value.name.downcase.hash.abs % 1000000
27
+ # Generate a unique ID based on both name and option value
28
+ # This ensures options with the same name but different values get different IDs
29
+ name_option_key = "#{option_value.name}_#{option_value.option}"
30
+ option_value.attributes["id"] = string_to_consistent_id(name_option_key)
30
31
  end
31
32
  end
32
33
  end
@@ -9,8 +9,8 @@ module EPlat::Woocommerce
9
9
  if self.options.present?
10
10
  self.options.each do |option|
11
11
  if (option.attributes["id"].nil? || option.attributes["id"] == 0) && option.name.present?
12
- # Use the hash of the name (lowercase) as a consistent ID
13
- option.attributes["id"] = option.name.downcase.hash.abs % 1000000
12
+ # Use a deterministic ID generation method
13
+ option.attributes["id"] = string_to_consistent_id(option.name)
14
14
  end
15
15
  end
16
16
  end
@@ -38,7 +38,6 @@ module EPlat::Woocommerce
38
38
  end
39
39
  end
40
40
 
41
-
42
41
  def common_product_variant_attributes
43
42
  [
44
43
  "body_html",
@@ -1,3 +1,3 @@
1
1
  module EPlat
2
- VERSION = "1.1.0-rc.6"
2
+ VERSION = "1.1.0-rc.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.6
4
+ version: 1.1.0.pre.rc.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - oliwoodsuk