Changeset 3249255
- Timestamp:
- 03/02/2025 04:54:53 PM (13 months ago)
- Location:
- subscriptions-for-woo
- Files:
-
- 2 edited
-
tags/2.4.5/classes/PPSFWOO/class-ppsfwoo-order.php (modified) (6 diffs)
-
trunk/classes/PPSFWOO/class-ppsfwoo-order.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
subscriptions-for-woo/tags/2.4.5/classes/PPSFWOO/class-ppsfwoo-order.php
r3248886 r3249255 144 144 145 145 // 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'])) { 147 147 148 148 $fee->set_tax_class(self::$tax_rate_data['tax_rate_slug']); … … 193 193 $fee_amount = floatval($payment_preferences['setup_fee']['value']); 194 194 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); 196 196 197 197 $order->add_item($fee); … … 212 212 } 213 213 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 216 216 $item->set_tax_class(self::$tax_rate_data['tax_rate_slug']); 217 218 $item->set_subtotal(self::tax($item->get_subtotal()));219 217 220 218 } … … 222 220 $item->save(); 223 221 } 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 238 222 } 239 223 … … 242 226 self::$tax_rate_data = $Subscriber->plan->get_tax_rate_data(); 243 227 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 252 228 $order = wc_create_order(); 253 229 … … 270 246 $order->calculate_totals(); 271 247 272 $order->set_total(self::tax(self::$order_total));273 274 248 $order->set_discount_total(0); 275 249 -
subscriptions-for-woo/trunk/classes/PPSFWOO/class-ppsfwoo-order.php
r3248886 r3249255 144 144 145 145 // 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'])) { 147 147 148 148 $fee->set_tax_class(self::$tax_rate_data['tax_rate_slug']); … … 193 193 $fee_amount = floatval($payment_preferences['setup_fee']['value']); 194 194 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); 196 196 197 197 $order->add_item($fee); … … 212 212 } 213 213 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 216 216 $item->set_tax_class(self::$tax_rate_data['tax_rate_slug']); 217 218 $item->set_subtotal(self::tax($item->get_subtotal()));219 217 220 218 } … … 222 220 $item->save(); 223 221 } 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 238 222 } 239 223 … … 242 226 self::$tax_rate_data = $Subscriber->plan->get_tax_rate_data(); 243 227 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 252 228 $order = wc_create_order(); 253 229 … … 270 246 $order->calculate_totals(); 271 247 272 $order->set_total(self::tax(self::$order_total));273 274 248 $order->set_discount_total(0); 275 249
Note: See TracChangeset
for help on using the changeset viewer.