diff --git a/prerender/seo/feeds.cjs b/prerender/seo/feeds.cjs index 119bb84..b13c537 100644 --- a/prerender/seo/feeds.cjs +++ b/prerender/seo/feeds.cjs @@ -11,6 +11,22 @@ Crawl-delay: 0 return robotsTxt; }; +// Helper function to determine unit pricing measure based on product data +const determineUnitPricingMeasure = (product) => { + // Use the actual unit data from the product structure + if (product.fEinheitMenge && product.cEinheit) { + const amount = parseFloat(product.fEinheitMenge); + const unit = product.cEinheit.trim(); + + if (amount > 0 && unit) { + return `${amount} ${unit}`; + } + } + + // Return null if no unit data available - don't corrupt data with fallbacks + return null; +}; + const generateProductsXml = (allProductsData = [], baseUrl, config) => { const currentDate = new Date().toISOString(); @@ -325,6 +341,13 @@ const generateProductsXml = (allProductsData = [], baseUrl, config) => { ${parseFloat(product.weight).toFixed(2)} g`; } + // Add unit pricing measure (required by German law for many products) + const unitPricingMeasure = determineUnitPricingMeasure(product); + if (unitPricingMeasure) { + productsXml += ` + ${unitPricingMeasure}`; + } + productsXml += ` `; diff --git a/src/components/AddToCartButton.js b/src/components/AddToCartButton.js index 40dcc79..05e0457 100644 --- a/src/components/AddToCartButton.js +++ b/src/components/AddToCartButton.js @@ -51,6 +51,8 @@ class AddToCartButton extends Component { seoName: this.props.seoName, pictureList: this.props.pictureList, price: this.props.price, + fGrundPreis: this.props.fGrundPreis, + cGrundEinheit: this.props.cGrundEinheit, quantity: 1, weight: this.props.weight, vat: this.props.vat, diff --git a/src/components/Product.js b/src/components/Product.js index 5fee10e..1b8ce82 100644 --- a/src/components/Product.js +++ b/src/components/Product.js @@ -68,7 +68,7 @@ class Product extends Component { render() { const { id, name, price, available, manufacturer, seoName, - currency, vat, massMenge, massEinheit, thc, + currency, vat, cGrundEinheit, fGrundPreis, thc, floweringWeeks,incoming, neu, weight, versandklasse, availableSupplier } = this.props; @@ -341,8 +341,8 @@ class Product extends Component { - {massMenge != 1 && massEinheit && ( - ({new Intl.NumberFormat('de-DE', {style: 'currency', currency: currency || 'EUR'}).format(price/massMenge)}/{massEinheit}) + {cGrundEinheit && fGrundPreis && fGrundPreis != price && ( + ({new Intl.NumberFormat('de-DE', {style: 'currency', currency: currency || 'EUR'}).format(fGrundPreis)}/{cGrundEinheit}) )} {/*incoming*/} @@ -358,7 +358,7 @@ class Product extends Component { > - + diff --git a/src/components/ProductDetailPage.js b/src/components/ProductDetailPage.js index 5e84826..5073701 100644 --- a/src/components/ProductDetailPage.js +++ b/src/components/ProductDetailPage.js @@ -452,7 +452,11 @@ class ProductDetailPage extends Component { inkl. {product.vat}% MwSt. + {product.cGrundEinheit && product.fGrundPreis && ( + <>; {new Intl.NumberFormat('de-DE', {style: 'currency', currency: 'EUR'}).format(product.fGrundPreis)}/{product.cGrundEinheit} + )} + {product.versandklasse && product.versandklasse != "standard" && product.versandklasse != "kostenlos" && ( @@ -516,12 +520,15 @@ class ProductDetailPage extends Component { available={product.available} id={product.id} availableSupplier={product.availableSupplier} + cGrundEinheit={product.cGrundEinheit} + fGrundPreis={product.fGrundPreis} price={product.price} vat={product.vat} weight={product.weight} name={cleanProductName(product.name)} versandklasse={product.versandklasse} /> + { }, 200); }; + // Handle enter icon click + const handleEnterClick = () => { + delete window.currentSearchQuery; + setShowSuggestions(false); + if (searchQuery.trim()) { + navigate(`/search?q=${encodeURIComponent(searchQuery)}`); + } + }; + // Clean up timers on unmount React.useEffect(() => { return () => { @@ -244,9 +255,23 @@ const SearchBar = () => { ), - endAdornment: loadingSuggestions && ( + endAdornment: ( - + {loadingSuggestions && } + + + ), sx: { borderRadius: 2, bgcolor: "background.paper" },