Plugin Directory

Changeset 3249255


Ignore:
Timestamp:
03/02/2025 04:54:53 PM (13 months ago)
Author:
marknokes
Message:

amend previous commit

Location:
subscriptions-for-woo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • subscriptions-for-woo/tags/2.4.5/classes/PPSFWOO/class-ppsfwoo-order.php

    r3248886 r3249255  
    144144
    145145        // Need this here because the loop below over $order->get_items() does not contain fee(s)
    146         if(self::$tax_rate_data['tax_rate'] !== 0) {
     146        if(self::$tax_rate_data['tax_rate'] !== 0 && empty(self::$tax_rate_data['inclusive'])) {
    147147               
    148148            $fee->set_tax_class(self::$tax_rate_data['tax_rate_slug']);
     
    193193            $fee_amount = floatval($payment_preferences['setup_fee']['value']);
    194194
    195             $fee = self::create_fee('One-time setup fee', $fee_amount, self::$tax_rate_data);
     195            $fee = self::create_fee('One-time setup fee', $fee_amount);
    196196
    197197            $order->add_item($fee);
     
    212212            }
    213213
    214             if(self::$tax_rate_data['tax_rate'] !== 0) {
    215                    
     214            if(self::$tax_rate_data['tax_rate'] !== 0 && empty(self::$tax_rate_data['inclusive'])) {
     215
    216216                $item->set_tax_class(self::$tax_rate_data['tax_rate_slug']);
    217 
    218                 $item->set_subtotal(self::tax($item->get_subtotal()));
    219217
    220218            }
     
    222220            $item->save();
    223221        }
    224     }
    225 
    226     private static function tax($price)
    227     {
    228         if(0 === self::$tax_rate_data['tax_rate']) {
    229 
    230             return $price;
    231 
    232         }
    233 
    234         $tax = ((self::$tax_rate_data['tax_rate'] / 100) * $price);
    235 
    236         return empty(self::$tax_rate_data['inclusive']) ? $price + $tax: $price;
    237 
    238222    }
    239223
     
    242226        self::$tax_rate_data = $Subscriber->plan->get_tax_rate_data();
    243227
    244         $include_tax = !empty(self::$tax_rate_data['inclusive']) ? 'yes' : 'no';
    245 
    246         add_filter('pre_option_woocommerce_prices_include_tax', function () use ($include_tax) {
    247 
    248             return $include_tax;
    249 
    250         });
    251 
    252228        $order = wc_create_order();
    253229
     
    270246        $order->calculate_totals();
    271247
    272         $order->set_total(self::tax(self::$order_total));
    273 
    274248        $order->set_discount_total(0);
    275249
  • subscriptions-for-woo/trunk/classes/PPSFWOO/class-ppsfwoo-order.php

    r3248886 r3249255  
    144144
    145145        // Need this here because the loop below over $order->get_items() does not contain fee(s)
    146         if(self::$tax_rate_data['tax_rate'] !== 0) {
     146        if(self::$tax_rate_data['tax_rate'] !== 0 && empty(self::$tax_rate_data['inclusive'])) {
    147147               
    148148            $fee->set_tax_class(self::$tax_rate_data['tax_rate_slug']);
     
    193193            $fee_amount = floatval($payment_preferences['setup_fee']['value']);
    194194
    195             $fee = self::create_fee('One-time setup fee', $fee_amount, self::$tax_rate_data);
     195            $fee = self::create_fee('One-time setup fee', $fee_amount);
    196196
    197197            $order->add_item($fee);
     
    212212            }
    213213
    214             if(self::$tax_rate_data['tax_rate'] !== 0) {
    215                    
     214            if(self::$tax_rate_data['tax_rate'] !== 0 && empty(self::$tax_rate_data['inclusive'])) {
     215
    216216                $item->set_tax_class(self::$tax_rate_data['tax_rate_slug']);
    217 
    218                 $item->set_subtotal(self::tax($item->get_subtotal()));
    219217
    220218            }
     
    222220            $item->save();
    223221        }
    224     }
    225 
    226     private static function tax($price)
    227     {
    228         if(0 === self::$tax_rate_data['tax_rate']) {
    229 
    230             return $price;
    231 
    232         }
    233 
    234         $tax = ((self::$tax_rate_data['tax_rate'] / 100) * $price);
    235 
    236         return empty(self::$tax_rate_data['inclusive']) ? $price + $tax: $price;
    237 
    238222    }
    239223
     
    242226        self::$tax_rate_data = $Subscriber->plan->get_tax_rate_data();
    243227
    244         $include_tax = !empty(self::$tax_rate_data['inclusive']) ? 'yes' : 'no';
    245 
    246         add_filter('pre_option_woocommerce_prices_include_tax', function () use ($include_tax) {
    247 
    248             return $include_tax;
    249 
    250         });
    251 
    252228        $order = wc_create_order();
    253229
     
    270246        $order->calculate_totals();
    271247
    272         $order->set_total(self::tax(self::$order_total));
    273 
    274248        $order->set_discount_total(0);
    275249
Note: See TracChangeset for help on using the changeset viewer.