marcush73
Verfasste Forenbeiträge
-
Forum: WooCommerce
Als Antwort auf: White Screen of Death nach Update auf PHP 8.3@la-geek vielen Dank, das hat mir sehr weitergeholfen. Ich habe das Memory Limit erhöht und von dem Zeitpunkt ab haben, WooCommerce und alle abhängigen Plugins wieder zuverlässig funktioniert.
Forum: WooCommerce
Als Antwort auf: 5% Rabatt für SelbstabholerHi zusammen, ich habe den Code von Stackoverflow ausprobiert. Allerdings wird der Wert nicht korrekt berechnet. Ich habe einen Warenkorb mit einer Zwischensumme von 14,70 €.
5% davon wären 0,735 €. D.h. Die Gesamtsumme müsste eigentlich 13,97 € sein.
Im Shop sind es aber Gesamt 14,04 €. Warum ist das so? Hat jemand eine Idee? Ich komme nicht dahinter.add_filter('woocommerce_package_rates', 'local_pickup_percentage_discount', 12, 2); function local_pickup_percentage_discount( $rates, $package ){ if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return $rates; // HERE define the discount percentage $percentage = 5; // 5% $subtotal = WC()->cart->get_subtotal(); // Loop through the shipping taxes array foreach ( $rates as $rate_key => $rate ){ $has_taxes = false; // Targetting "flat rate" if( 'local_pickup' === $rate->method_id ){ // Add the Percentage to the label name (otional $rates[$rate_key]->label .= ' ( - ' . $percentage . '% )'; // Get the initial cost $initial_cost = $new_cost = $rates[$rate_key]->cost; // Calculate new cost $new_cost = -$subtotal * $percentage / 100; // Set the new cost $rates[$rate_key]->cost = $new_cost; // Taxes rate cost (if enabled) $taxes = []; // Loop through the shipping taxes array (as they can be many) foreach ($rates[$rate_key]->taxes as $key => $tax){ if( $rates[$rate_key]->taxes[$key] > 0 ){ // Get the initial tax cost $initial_tax_cost = $new_tax_cost = $rates[$rate_key]->taxes[$key]; // Get the tax rate conversion $tax_rate = $initial_tax_cost / $initial_cost; // Set the new tax cost $taxes[$key] = $new_cost * $tax_rate; $has_taxes = true; // Enabling tax } } if( $has_taxes ) $rates[$rate_key]->taxes = $taxes; } } return $rates; }
Grüße, Marcus
Forum: WooCommerce
Als Antwort auf: 5% Rabatt für SelbstabholerDas war der Plan 🙂 Ich werde schauen, dass ich den Code von stackoverflow zum Laufen bekomme und sollte das aus irgendeinem Grund nicht funktionieren, wäre das Plugin Plan B. Vielen Dank nochmals!
Forum: WooCommerce
Als Antwort auf: 5% Rabatt für SelbstabholerServus Souri, vielen Dank für die wertvollen Tips. Ich werde das ausprobieren und berichten welche Variante für meinen Case besser funktioniert hat. Beste Grüße, Marcus
- Diese Antwort wurde geändert vor 2 Jahren, 3 Monaten von marcush73.