@fernashes
thank you for the fast respond and the interesting article.
It’s no problem I also speak english well.
I have found a solution myself by using the built in shipping classes.
I use one for the products that have free shipping and the other for the few products that need a shipping flatrate.
There was only a small display issue.
Woocommerce will display the method name as defined in the wordpress backend, which default is “Versandkostenpauschale” for a flatrate shipping it will be display even if the price is set to 0.
To change that I’ve added the following snippet to my child themes functions.php:
/**
* Setzt Versandmethoden-Label auf das Woocommerce Standardlabel für kostenlosen Versand wenn der Preis der Methode <= 0 ist.
* @param string $label Label der Versandmethode (Standard: Versandkostenpauschale)
* @param WC_Shipping_Rate $method Versandmethode
*/
function mjm_woocommerce_cart_shipping_method_full_label($label,$method){
/* Prüfen ob die Kosten der Versandmethode <= 0 sind */
if($method->cost <= 0){
/* Auf Standardwert für kostenlosen Versand stellen */
$label = __('Free Shipping','woocommerce');
}
return $label;
}
add_filter('woocommerce_cart_shipping_method_full_label','mjm_woocommerce_cart_shipping_method_full_label',10,2);
In Deutsch:
vielen Dank für die schnelle Rückmeldung und den interessanten Artikel.
Ihre Antwort war kein Problem, da ich auch Englisch gut beherrsche.
Ich habe selbst eine L?sung gefunden, indem ich die integrierten Versandklassen benutze. Ich verwende eine Klasse für die Produkte die kostenlos versendet werden und eine weitere für die wenigen Produkte für die eine Versandkostenpauschale ben?tigt wird.
Es gab nur ein kleines Anzeige-Problem.
Woocommerce zeigt den Methodenname der Versandart wie im Woocommerce Backend an, welcher standardm??ig “Versandkostenpauschale” für pauschale Versandkosten ist, auch wenn der Preis hierfür auf 0 eingestellt ist.
Um dies zu ?ndern habe ich folgendes Snippet zu der functions.php meines Child-Themes hinzugefügt:
/**
* Setzt Versandmethoden-Label auf das Woocommerce Standardlabel für kostenlosen Versand wenn der Preis der Methode <= 0 ist.
* @param string $label Label der Versandmethode (Standard: Versandkostenpauschale)
* @param WC_Shipping_Rate $method Versandmethode
*/
function mjm_woocommerce_cart_shipping_method_full_label($label,$method){
/* Prüfen ob die Kosten der Versandmethode <= 0 sind */
if($method->cost <= 0){
/* Auf Standardwert für kostenlosen Versand stellen */
$label = __('Free Shipping','woocommerce');
}
return $label;
}
add_filter('woocommerce_cart_shipping_method_full_label','mjm_woocommerce_cart_shipping_method_full_label',10,2);
-
This reply was modified 6 years, 4 months ago by
mumbomedia. Reason: Kommentare zum besseren Verst?ndnis hinzugefügt