Add unit pricing measure to product XML generation in feeds.cjs. Updated Product, ProductDetailPage, and AddToCartButton components to support new pricing fields (fGrundPreis, cGrundEinheit) for compliance with German regulations. Enhanced SearchBar with enter icon functionality for improved user experience.
This commit is contained in:
@@ -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) => {
|
||||
<g:shipping_weight>${parseFloat(product.weight).toFixed(2)} g</g:shipping_weight>`;
|
||||
}
|
||||
|
||||
// Add unit pricing measure (required by German law for many products)
|
||||
const unitPricingMeasure = determineUnitPricingMeasure(product);
|
||||
if (unitPricingMeasure) {
|
||||
productsXml += `
|
||||
<g:unit_pricing_measure>${unitPricingMeasure}</g:unit_pricing_measure>`;
|
||||
}
|
||||
|
||||
productsXml += `
|
||||
</item>`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user