Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add structured data fields to Spree stores #6113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rahulsingh321
Copy link
Contributor

@rahulsingh321 rahulsingh321 commented Feb 10, 2025

Summary

This Commit provides the possibility to store legal information in the
store resource. Given the wide array of different information required
by country, the information stored here provides a baseline for most
countries, but might need to be augmented in some jurisdictions. This
commit is not meant as legal advisory. Inform yourself about eventual
requirements in your country of operation.

Some additional information that might be needed:

  • Legal Representative,
  • Share Capital of the company,
  • Contacts for privacy.

Schema.org has a schema to markup organizations that has been widely
adopted by various search engines:

https://schema.org/Organization Support / Docs
Bing https://www.bing.com/webmasters/help/?topicid=cc507c09
Google https://developers.google.com/search/docs/appearance/structured-data/organization
Yandex https://yandex.com/support/webmaster/schema-org/what-is-schema-org.html

This update allows to return all organization data on frontend via jsonb
if implemented according to schema documentation on a per store basis
and edit the data via API and Backend (Old / New).

The implemented fields are:

  • legal_name,
  • contact_email,
  • contact_phone,
  • vat_id,
  • tax_id,
  • address1,
  • address2,
  • Zip code and city,
  • state_name,
  • country_id,
  • and state_id.

Some additional notes regarding the size of the commit:
While this commit seems massive in size, no functionality has been added
apart from storing the values, no logical changes have been made, hence
the commit while bigger in size is simple to analyse. Apart from testing
routines, this commit does not contain functional code. Where possible
the structure of current address forms has been adopted.

Fixes #6173

Screenshot

Screenshot from 2025-03-02 17-48-07
Screenshot from 2025-03-02 17-47-52
Screenshot from 2025-03-02 17-47-35
Sample-Store-Stores-03-04-2025_10_02_PM

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@github-actions github-actions bot added changelog:solidus_api Changes to the solidus_api gem changelog:solidus_backend Changes to the solidus_backend gem labels Feb 10, 2025
@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label Feb 10, 2025
@rahulsingh321 rahulsingh321 changed the title Added fields to store for organisational structured data for SEO Added fields to store for organisation structured data for SEO Feb 10, 2025
@rahulsingh321 rahulsingh321 force-pushed the 5905-add-store-fields branch 5 times, most recently from 5221825 to 4d128b4 Compare February 17, 2025 19:35
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.86%. Comparing base (7d8a10d) to head (fc8e744).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6113      +/-   ##
==========================================
+ Coverage   86.64%   88.86%   +2.21%     
==========================================
  Files         514      838     +324     
  Lines       11894    18234    +6340     
==========================================
+ Hits        10306    16203    +5897     
- Misses       1588     2031     +443     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rahulsingh321 rahulsingh321 force-pushed the 5905-add-store-fields branch 2 times, most recently from 747e3ab to 5ca04d7 Compare February 20, 2025 14:56
@github-actions github-actions bot added changelog:solidus_sample Changes to the solidus_sample gem changelog:solidus_admin labels Feb 21, 2025
@github-actions github-actions bot added changelog:solidus_sample Changes to the solidus_sample gem changelog:solidus_admin and removed changelog:solidus_sample Changes to the solidus_sample gem changelog:solidus_admin labels Feb 24, 2025
@github-actions github-actions bot removed the changelog:solidus_sample Changes to the solidus_sample gem label Feb 25, 2025
@rahulsingh321 rahulsingh321 force-pushed the 5905-add-store-fields branch 7 times, most recently from 34599c8 to a0b341d Compare February 26, 2025 18:23
@rahulsingh321 rahulsingh321 force-pushed the 5905-add-store-fields branch 2 times, most recently from c84b99e to bbff7bc Compare February 27, 2025 17:22
@fthobe
Copy link
Contributor

fthobe commented Feb 27, 2025

  1. Please restructure the form order as in attached image
  2. contact email is missing on forms
  3. Save button should be at right top and right bottom as in figma (https://www.figma.com/design/h7eZRxh8KhPakTMr7c9NlB/Solidus-%E2%80%94-Admin-Dashboard?node-id=419-7816&p=f&t=u5VE4L1wTTlfzrkw-0)
  4. Make separate cards according to mock up for old backend
  5. Add context info to VAT-ID field: vat-id-hint for en.yml "Enter your VAT-ID without the Country Prefix (eg IT for Italy or DE for Germany) but solely the identification string."
Screenshot 2025-02-27 at 19 59 39

@fthobe
Copy link
Contributor

fthobe commented Feb 27, 2025

@rahulsingh321 in future PRs I kindly ask you to follow @tvdeyen more on the commit structure.
Commit 1: Add Columns
Commit 2: Add API and API Description
Commit 3: Add tests
Commit 4: Add Admin UI Admin Backend
Commit 4: Add Admin UI New Admin Backend

@rahulsingh321 rahulsingh321 force-pushed the 5905-add-store-fields branch 6 times, most recently from 76b10b9 to a7fa008 Compare March 3, 2025 17:33
@rahulsingh321 rahulsingh321 changed the title Added fields to store for organisation structured data for SEO [Compliance / SEO] Add structured data fields to Spree stores Mar 4, 2025
@rahulsingh321 rahulsingh321 force-pushed the 5905-add-store-fields branch from a7fa008 to fc8e744 Compare March 4, 2025 07:16
@fthobe
Copy link
Contributor

fthobe commented Mar 4, 2025

@tvdeyen @kennyadsl looks good to me
I know it looks like a huge commit but it's only a couple of columns on stores without any logic other than altering the content. We also found a little bug in the formfields during the work that @chaimann had the courtesy to fix.
I am making a change request against schema.org tonight hoping to alter it to reflect all legally required data across all jurisdictions but that depends on them to accept it.

@rahulsingh321 rahulsingh321 marked this pull request as ready for review March 4, 2025 18:03
@rahulsingh321 rahulsingh321 requested a review from a team as a code owner March 4, 2025 18:03
This Commit provides the possibility to store legal information in the
store resource. Given the wide array of different information required
by country, the information stored here provides a baseline for most
countries, but might need to be augmented in some jurisdictions. This
commit is not meant as legal advisory. Inform yourself about eventual
requirements in your country of operation.

Some additional information that might be needed:
 - Legal Representative,
 - Share Capital of the company,
 - Contacts for privacy.

Schema.org has a schema to markup organizations that has been widely
adopted by various search engines:

|        | https://schema.org/Organization Support / Docs
|
|--------|-----------------------------------------------------------------------------------|
| Bing   | https://www.bing.com/webmasters/help/?topicid=cc507c09
|
| Google |
https://developers.google.com/search/docs/appearance/structured-data/organization
|
| Yandex |
https://yandex.com/support/webmaster/schema-org/what-is-schema-org.html
|

This update allows to return all organization data on frontend via jsonb
if implemented according to schema documentation on a per store basis
and edit the data via API and Backend (Old / New).

The implemented fields are:

- legal_name,
- contact_email,
- contact_phone,
- vat_id,
- tax_id,
- address1,
- address2,
- Zip code and city,
- state_name,
- country_id,
- and state_id.

Some additional notes regarding the size of the commit:
While this commit seems massive in size, no functionality has been added
apart from storing the values, no logical changes have been made, hence
the commit while bigger in size is simple to analyse. Apart from testing
routines, this commit does not contain functional code. Where possible
the structure of current address forms has been adopted.

Fixes solidusio#6173
@rahulsingh321 rahulsingh321 force-pushed the 5905-add-store-fields branch from fc8e744 to a1b1502 Compare March 6, 2025 18:36
@fthobe
Copy link
Contributor

fthobe commented Mar 6, 2025

@kennyadsl can we review this, it should be good to go.

@tvdeyen tvdeyen changed the title [Compliance / SEO] Add structured data fields to Spree stores Add structured data fields to Spree stores Mar 10, 2025
@tvdeyen
Copy link
Member

tvdeyen commented Mar 10, 2025

@fthobe please stop framing PRs and issues "your way" in the PR title. Thanks.

@fthobe
Copy link
Contributor

fthobe commented Mar 10, 2025

@fthobe please stop framing PRs and issues "your way" in the PR title. Thanks.

@tvdeyen could you suggest a better name to get a hang of it? The resource is stores and the fields we add are the structured data fields. Please advise, not being condescending, trying to learn.

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the existing address form component, instead of introducing a second one. Also the PR adds a general new admin form for managing stores, which is very much appreciated, but this should at least be a dedicated commit the extra builds on top of and should no be combined into one commit, otherwise it is hard to see what the actual change (from your PR title) is.

@@ -0,0 +1,56 @@
import { Controller } from "@hotwired/stimulus"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a address form component that handles states. Can we use that one instead of implementing a second one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can look into reusing the logic to pick a state. Does it make sense if everything else should be detached from the address table?

<%= form_for @store, url: solidus_admin.store_path(@store), html: { id: form_id } do |f| %>
<%= page_with_sidebar do %>
<%= page_with_sidebar_main do %>
<%= render component("ui/panel").new(title: t(".store_settings")) do %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why haven't you used the existing address form component?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't seem indicated to invoke the address list for performance reasons.
These values should be cached and provided separately as otherwise the address tabled needs to be used for values that in some scenarios could be embedded on every page depending on the implementation.

@fthobe
Copy link
Contributor

fthobe commented Mar 10, 2025

We should use the existing address form component, instead of introducing a second one. Also the PR adds a general new admin form for managing stores, which is very much appreciated, but this should at least be a dedicated commit the extra builds on top of and should no be combined into one commit, otherwise it is hard to see what the actual change (from your PR title) is.

We can separate the new admin from the rest.

<%= render component("ui/forms/field").text_field(f, :seo_title) %>
<%= render component("ui/forms/field").text_field(f, :meta_keywords) %>
<%= render component("ui/forms/field").text_area(f, :meta_description) %>
<%= render component("ui/forms/field").text_field(f, :tax_id) %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store_tax_id instead of tax_id

<%= render component("ui/forms/field").text_field(f, :meta_keywords) %>
<%= render component("ui/forms/field").text_area(f, :meta_description) %>
<%= render component("ui/forms/field").text_field(f, :tax_id) %>
<%= render component("ui/forms/field").text_field(f, :vat_id) %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store_vat_id instead of vat_id

@@ -354,18 +354,31 @@ en:
quantity: Quantity
variant: Variant
spree/store:
address: Address
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store_...

<%= form_for @store, url: solidus_admin.store_path(@store), html: { id: form_id } do |f| %>
<%= page_with_sidebar do %>
<%= page_with_sidebar_main do %>
<%= render component("ui/panel").new(title: t(".store_settings")) do %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't seem indicated to invoke the address list for performance reasons.
These values should be cached and provided separately as otherwise the address tabled needs to be used for values that in some scenarios could be embedded on every page depending on the implementation.

@@ -0,0 +1,56 @@
import { Controller } from "@hotwired/stimulus"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can look into reusing the logic to pick a state. Does it make sense if everything else should be detached from the address table?

@fthobe
Copy link
Contributor

fthobe commented Mar 10, 2025

@tvdeyen replied to your comments

@tvdeyen
Copy link
Member

tvdeyen commented Mar 10, 2025

@fthobe please stop framing PRs and issues "your way" in the PR title. Thanks.

@tvdeyen could you suggest a better name to get a hang of it? The resource is stores and the fields we add are the structured data fields. Please advise, not being condescending, trying to learn.

The name is ok, the "[Tag]"-Part is unnecessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_admin changelog:solidus_api Changes to the solidus_api gem changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Legal Information for Structured Data and mandatory Imprints
3 participants