/** * Rank-Math: Versand- und Rückgabe-Schema für Simple- und Variable-Produkte */ add_filter( 'rank_math/json_ld', function ( $data, $jsonld ) { /* Nur bei Produkt- und Produktgruppen-Markup eingreifen */ if ( empty( $data['richSnippet'] ) || ! in_array( $data['richSnippet']['@type'], [ 'Product', 'ProductGroup' ], true ) ) { return $data; } /* ---------- Versanddetails ----------------------------------------- */ $data['shippingDetails'] = [ '@context' => 'https://schema.org/', '@type' => 'OfferShippingDetails', '@id' => '#shipping_policy', /* Lauf- & Bearbeitungszeit */ 'deliveryTime' => [ '@type' => 'ShippingDeliveryTime', 'handlingTime' => [ '@type' => 'QuantitativeValue', 'minValue' => 0, 'maxValue' => 1, 'unitCode' => 'DAY', ], 'transitTime' => [ '@type' => 'QuantitativeValue', 'minValue' => 1, 'maxValue' => 2, 'unitCode' => 'DAY', ], ], /* Versandkosten + Schwelle für Gratisversand */ 'shippingRate' => [ '@type' => 'ShippingRateSettings', 'shippingRate' => [ '@type' => 'MonetaryAmount', 'value' => 6.9, // CHF 6.90 Standardversand 'currency' => 'CHF', ], 'freeShippingThreshold' => [ // gratis ab 69 CHF '@type' => 'MonetaryAmount', 'value' => 69, 'currency' => 'CHF', ], ], /* Zielregion */ 'shippingDestination' => [ '@type' => 'DefinedRegion', 'addressCountry' => 'CH', ], ]; /* ---------- Rückgaberichtlinie ------------------------------------ */ $data['hasMerchantReturnPolicy'] = [ '@context' => 'https://schema.org/', '@type' => 'MerchantReturnPolicy', '@id' => '#merchant_policy', 'applicableCountry' => 'CH', 'returnPolicyCountry' => 'CH', 'returnPolicyCategory' => 'https://schema.org/MerchantReturnFiniteReturnWindow', 'merchantReturnDays' => 30, 'returnMethod' => 'https://schema.org/ReturnByMail', 'returnFees' => 'https://schema.org/ReturnFeesCustomerResponsibility', // Kunde trägt Rückporto :contentReference[oaicite:0]{index=0} 'refundType' => 'https://schema.org/FullRefund', // voller Warenwert 'returnLabelSource' => 'https://schema.org/ReturnLabelCustomerResponsibility',// optional, aber passend ]; /* ---------- Verknüpfung mit dem Produkt-Markup -------------------- */ if ( 'Product' === $data['richSnippet']['@type'] ) { /* Simple-Produkt */ $data['richSnippet']['offers']['shippingDetails'] = [ '@id' => '#shipping_policy' ]; $data['richSnippet']['offers']['hasMerchantReturnPolicy'] = [ '@id' => '#merchant_policy' ]; return $data; } /* Varianten durchlaufen (ProductGroup) */ if ( ! empty( $data['richSnippet']['hasVariant'] ) ) { foreach ( $data['richSnippet']['hasVariant'] as $k => $variant ) { if ( empty( $variant['offers'] ) ) { continue; } $data['richSnippet']['hasVariant'][ $k ]['offers']['shippingDetails'] = [ '@id' => '#shipping_policy' ]; $data['richSnippet']['hasVariant'][ $k ]['offers']['hasMerchantReturnPolicy'] = [ '@id' => '#merchant_policy' ]; } } return $data; }, 99, 2 );
Noch keinen Account?
Erstelle ein Kundenkonto