Advertisement
milenbogoev

Fix for Free shipping label in Funnelkit

Feb 13th, 2025
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. function custom_shipping_label_based_on_cart_total($output, $method) {
  2.     $cart_total = WC()->cart->cart_contents_total;
  3.  
  4.     // SUMA ZA BEZPLATNA DOSTAVKA
  5.     $free_shipping_threshold = 200; //На мястото на 200 напишете сумата за безплатна доставка на вашият магазин!
  6.  
  7.     if ($cart_total >= $free_shipping_threshold) {
  8.         $output = __('Free Shipping', 'woocommerce');
  9.     } else {
  10.        
  11.         if ($method->cost > 0) {
  12.             $output = wc_price($method->cost);
  13.             if ($method->get_shipping_tax() > 0) {
  14.                 $label = wc_prices_include_tax() ? WC()->countries->ex_tax_or_vat() : WC()->countries->inc_tax_or_vat();
  15.                 $output .= ' <small class="tax_label">' . $label . '</small>';
  16.             }
  17.         } else {
  18.            
  19.             $output = '';
  20.         }
  21.     }
  22.  
  23.     return $output;
  24. }
  25. add_filter('wc_cart_totals_shipping_method_cost', 'custom_shipping_label_based_on_cart_total', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement