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

feat: add support for ListPrice and priceValidUntil in JSON-LD #39

Merged
merged 5 commits into from
Nov 5, 2024

Conversation

dylandepass
Copy link
Contributor

No description provided.

const image = this.product.images?.[0]?.url
?? findProductImage(this.product, this.variants)?.url;
const configurableProduct = this.variants && this.variants.length > 0;
const offers = configurableProduct ? this.variants : [this.product];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer adding the parent product as an offer. Will only use variants or product if no variants exist

if (specialToDate) {
const today = new Date();
const specialPriceToDate = new Date(specialToDate);
if (specialPriceToDate.getTime() >= today.getTime()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not 100% sure if we should filter this out if the sale has passed. This is what bulk does though. Also wondering about timezones..

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, not a huge fan since we wouldn't actually be publishing when the offer elapses, but seems like an edge case that shouldn't happen anyway.. worth keeping in mind for the publish triggering topic though

@@ -49,6 +49,16 @@ export const adapter = (config, variants) => variants.map(({ selections, product
},
selections: selections ?? [],
};

const specialToDate = product.attributes?.find((attr) => attr.name === 'special_to_date')?.value;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

special_to_date is a core attribute. So I think we are safe to use this as the default.

Copy link
Contributor

Choose a reason for hiding this comment

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

does this attribute exist on the variant? or on the product?

Copy link
Contributor Author

@dylandepass dylandepass Nov 5, 2024

Choose a reason for hiding this comment

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

Here we are pulling for the variant, but good point.. In the case of a simple product maybe we should also add for the product.

@dylandepass dylandepass requested a review from maxakuru November 5, 2024 18:24
Copy link
Contributor

@maxakuru maxakuru left a comment

Choose a reason for hiding this comment

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

🚀

if (specialToDate) {
const today = new Date();
const specialPriceToDate = new Date(specialToDate);
if (specialPriceToDate.getTime() >= today.getTime()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, not a huge fan since we wouldn't actually be publishing when the offer elapses, but seems like an edge case that shouldn't happen anyway.. worth keeping in mind for the publish triggering topic though

@dylandepass dylandepass merged commit e84a1e0 into main Nov 5, 2024
4 checks passed
@dylandepass dylandepass deleted the listprice branch November 5, 2024 19:16
Copy link

github-actions bot commented Nov 5, 2024

🎉 This PR is included in version 1.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants