Class: SpreeCmCommissioner::ProductCompletionSteps::SocialEntryUrl

Inherits:
SpreeCmCommissioner::ProductCompletionStep show all
Defined in:
app/models/spree_cm_commissioner/product_completion_steps/social_entry_url.rb

Constant Summary collapse

ORDER_ALLOWED_FIELDS =

Allowed fields per object (excludes private/reference fields like *_id, *_by_id, metadata, etc.)

%w[
  qr_data
  number
  state
  email
  total
  display_total
  item_total
  display_item_total
  adjustment_total
  display_adjustment_total
  created_at
  completed_at
  token
  phone_number
  country_code
  currency
  item_count
  channel
  special_instructions
].freeze
BILL_ADDRESS_ALLOWED_FIELDS =
%w[
  first_name
  last_name
  full_name
  address1
  address2
  city
  zipcode
  phone
  state_name
  alternative_phone
  company
  label
  age
  gender
].freeze
LINE_ITEM_ALLOWED_FIELDS =
%w[
  qr_data
  quantity
  price
  display_price
  from_date
  to_date
  number
  remark
  created_at
  updated_at
].freeze
GUEST_ALLOWED_FIELDS =
%w[
  qr_data
  first_name
  last_name
  full_name
  dob
  gender
  age
  phone_number
  address
  seat_number
  bib_number
  bib_prefix
  bib_index
  formatted_bib_number
  token
  social_contact
  country_code
  emergency_contact
  expectation
  other_occupation
  other_organization
  created_at
  updated_at
].freeze

Instance Method Summary collapse

Methods inherited from SpreeCmCommissioner::ProductCompletionStep

#construct_hash

Instance Method Details

#action_url_for(line_item) ⇒ Object

override



91
92
93
94
95
96
97
98
99
100
# File 'app/models/spree_cm_commissioner/product_completion_steps/social_entry_url.rb', line 91

def action_url_for(line_item)
  return nil if preferred_entry_point_link.blank?

  url = preferred_entry_point_link.dup
  url = replace_order_placeholders(url, line_item)
  url = replace_bill_address_placeholders(url, line_item)
  url = replace_line_item_placeholders(url, line_item)

  replace_guest_placeholders(url, line_item)
end

#completed?(line_item) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
105
106
107
# File 'app/models/spree_cm_commissioner/product_completion_steps/social_entry_url.rb', line 102

def completed?(line_item)
  return false if line_item.completion_steps.blank?

  step_data = line_item.completion_steps.find { |step| step['position'].to_s == position.to_s }
  step_data&.dig('completed_at').present?
end

#supported_fieldsHash

Returns a hash of all supported placeholder fields grouped by object type. Used by the admin UI to display available placeholders when configuring the entry_point_link template. Example usage in template: SpreeCmCommissioner::ProductCompletionSteps::SocialEntryUrl.orderorder.number, SpreeCmCommissioner::ProductCompletionSteps::SocialEntryUrl.bill_addressbill_address.first_name, SpreeCmCommissioner::ProductCompletionSteps::SocialEntryUrl.line_itemline_item.quantity, .email

Returns:

  • (Hash)

    Hash with keys :order, :bill_address, :line_item, :guests Each key maps to an array of allowed field names for that object type



115
116
117
118
119
120
121
122
# File 'app/models/spree_cm_commissioner/product_completion_steps/social_entry_url.rb', line 115

def supported_fields
  {
    order: ORDER_ALLOWED_FIELDS,
    bill_address: BILL_ADDRESS_ALLOWED_FIELDS,
    line_item: LINE_ITEM_ALLOWED_FIELDS,
    guests: GUEST_ALLOWED_FIELDS
  }
end