Changeset 3844131
- Timestamp:
- 12/04/2026 09:57:55 AM (less than one hour ago)
- Location:
- a2z-fedex-shipping
- Files:
-
- 1 deleted
- 2 edited
- 3 copied
-
tags/5.1.13 (copied) (copied from a2z-fedex-shipping/trunk )
-
tags/5.1.13/a2zfedex_basic.php (copied) (copied from a2z-fedex-shipping/trunk/a2zfedex_basic.php ) (8 diffs)
-
tags/5.1.13/controllors/shipi_ajax_handler.php (deleted)
-
tags/5.1.13/readme.txt (copied) (copied from a2z-fedex-shipping/trunk/readme.txt ) (2 diffs)
-
trunk/a2zfedex_basic.php (modified) (8 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
a2z-fedex-shipping/tags/5.1.13/a2zfedex_basic.php
r3793984 r3844131 4 4 * Plugin URI: https://myshipi.com/ 5 5 * Description: Realtime Shipping Rates, shipping labels. 6 * Version: 5.1.1 26 * Version: 5.1.13 7 7 * Author: Shipi 8 8 * Author URI: https://myshipi.com/ … … 2242 2242 } 2243 2243 2244 $net_totals = $this->shipi_get_net_order_totals($order, $order_data); 2244 2245 $data = array(); 2245 2246 $data['integrated_key'] = $general_settings['hitshippo_fedex_shippo_int_key']; … … 2317 2318 "inv_letterhead" => isset($general_settings['hitshippo_fedex_inv_letterhead']) ? $general_settings['hitshippo_fedex_inv_letterhead'] : '', 2318 2319 "ship_price" => $shipping_charge, 2319 "other_charges" => apply_filters("shipi_fedex_other_charges", (isset($order_data["total_tax"]) && $order_data["total_tax"] > 0 ? $order_data["total_tax"] : 0), $order_data),2320 "order_total" => isset($order_data['total']) ? $order_data['total'] : 0,2320 "other_charges" => apply_filters("shipi_fedex_other_charges", $net_totals['total_tax'], $order_data), 2321 "order_total" => $net_totals['total'], 2321 2322 "custom" => apply_filters("shipi_fedex_custom_values", array(), $_POST), 2322 "order_total_tax" => isset($order_data['total_tax']) ? $order_data['total_tax'] : 0,2323 "order_total_tax" => $net_totals['total_tax'], 2323 2324 ); 2324 2325 … … 3089 3090 // $order_shipping_email = $order_data['billing']['email']; 3090 3091 3091 $shipping_charge = $order_data['shipping_total']; 3092 $net_totals = $this->shipi_get_net_order_totals($order, $order_data); 3093 $shipping_charge = $net_totals['shipping_total']; 3092 3094 $handling_charge = (float) $order_data['discount_total']; 3093 3095 … … 3227 3229 "inv_letterhead" => isset($general_settings['hitshippo_fedex_inv_letterhead']) ? $general_settings['hitshippo_fedex_inv_letterhead'] : '', 3228 3230 "ship_price" => $shipping_charge, 3229 "other_charges" => apply_filters("shipi_fedex_other_charges", (isset($order_data["total_tax"]) && $order_data["total_tax"] > 0 ? $order_data["total_tax"] : 0), $order_data),3231 "other_charges" => apply_filters("shipi_fedex_other_charges", $net_totals['total_tax'], $order_data), 3230 3232 "handling_price" => ($handling_charge > 0 ? ((-1) * $handling_charge) : 0), 3231 3233 "ship_date" => isset($_POST["ship_date"]) ? $_POST["ship_date"] : "", 3232 "order_total" => isset($order_data['total']) ? $order_data['total'] : 0,3233 "order_total_tax" => isset($order_data['total_tax']) ? $order_data['total_tax'] : 0,3234 "order_total" => $net_totals['total'], 3235 "order_total_tax" => $net_totals['total_tax'], 3234 3236 "custom" => apply_filters("shipi_fedex_custom_values", array(), $_POST), 3235 3237 "label" => $create_shipment_for, … … 3285 3287 } 3286 3288 } 3289 /** 3290 * Return remaining quantity and line total after refunds, or false when an item is fully refunded. 3291 */ 3292 private function shipi_get_net_order_item($order, $item, $product_data) 3293 { 3294 $qty = isset($product_data['quantity']) ? (float) $product_data['quantity'] : 0.0; 3295 $refunded_qty = method_exists($order, 'get_qty_refunded_for_item') 3296 ? abs((float) $order->get_qty_refunded_for_item($item->get_id())) 3297 : 0.0; 3298 $remaining_qty = $qty - $refunded_qty; 3299 3300 if ($remaining_qty <= 0) { 3301 return false; 3302 } 3303 3304 $line_total = isset($product_data['total']) ? (float) $product_data['total'] : 0.0; 3305 $refunded_total = method_exists($order, 'get_total_refunded_for_item') 3306 ? abs((float) $order->get_total_refunded_for_item($item->get_id())) 3307 : 0.0; 3308 $remaining_total = $line_total - $refunded_total; 3309 3310 // Exclude items refunded by dollar amount without a refunded quantity; keep unrefunded $0 promo items. 3311 if ($line_total > 0 && round($remaining_total, 2) <= 0) { 3312 return false; 3313 } 3314 3315 return array( 3316 'remaining_qty' => $remaining_qty, 3317 'remaining_total' => $remaining_total, 3318 ); 3319 } 3320 3321 /** 3322 * Return order total, tax, and shipping net of WooCommerce refunds. 3323 */ 3324 private function shipi_get_net_order_totals($order, $order_data) 3325 { 3326 $total = isset($order_data['total']) ? (float) $order_data['total'] : 0.0; 3327 $tax = isset($order_data['total_tax']) ? (float) $order_data['total_tax'] : 0.0; 3328 $shipping = isset($order_data['shipping_total']) ? (float) $order_data['shipping_total'] : 0.0; 3329 3330 if (method_exists($order, 'get_total_refunded')) { 3331 $total = max(0.0, round($total - abs((float) $order->get_total_refunded()), 2)); 3332 } 3333 if (method_exists($order, 'get_total_tax_refunded')) { 3334 $tax = max(0.0, round($tax - abs((float) $order->get_total_tax_refunded()), 2)); 3335 } 3336 if (method_exists($order, 'get_total_shipping_refunded')) { 3337 $shipping = max(0.0, round($shipping - abs((float) $order->get_total_shipping_refunded()), 2)); 3338 } 3339 3340 return array( 3341 'total' => $total, 3342 'total_tax' => $tax, 3343 'shipping_total' => $shipping, 3344 ); 3345 } 3346 3287 3347 private function get_products_on_order($general_settings = [], $order = []) 3288 3348 { … … 3298 3358 $product_data = $item->get_data(); 3299 3359 3300 $refunded_qty = $order->get_qty_refunded_for_item( $item->get_id() ); 3301 $remaining_qty = $product_data['quantity'] - abs($refunded_qty); 3302 3303 if ($remaining_qty <= 0) { 3360 $net_item = $this->shipi_get_net_order_item($order, $item, $product_data); 3361 if ($net_item === false) { 3304 3362 continue; 3305 3363 } 3364 $remaining_qty = $net_item['remaining_qty']; 3365 $remaining_total = $net_item['remaining_total']; 3306 3366 3307 3367 $product = array(); … … 3344 3404 } 3345 3405 $product['product_name'] = apply_filters("shipi_product_name_change", str_replace('"', '', $getproduct->get_name()), $getproduct->get_id()); 3346 $refunded_total = $order->get_total_refunded_for_item( $item->get_id() ); 3347 $remaining_total = $product_data['total'] - abs($refunded_total); 3348 $product['price'] = (isset($remaining_total) && $remaining_total > 0) ? round($remaining_total/$remaining_qty, 2): $getproduct->get_price(); 3406 $product['price'] = ($remaining_total > 0) ? round($remaining_total/$remaining_qty, 2) : $getproduct->get_price(); 3349 3407 $product['width'] = (!empty($getproduct->get_width())) ? round(wc_get_dimension($getproduct->get_width(),$mod_dim_unit,$woo_dim_unit)) : ''; 3350 3408 $product['height'] = (!empty($getproduct->get_height())) ? round(wc_get_dimension($getproduct->get_height(),$mod_dim_unit,$woo_dim_unit)) : ''; -
a2z-fedex-shipping/tags/5.1.13/readme.txt
r3793984 r3844131 5 5 Tested up to: 7.0 6 6 Requires PHP: 5.6 7 Stable tag: 5.1.1 27 Stable tag: 5.1.13 8 8 License: GPLv3 or later License 9 9 URI: http://www.gnu.org/licenses/gpl-3.0.html … … 159 159 160 160 == Changelog == 161 = 5.1.13 = 162 * Fixed: Exclude items refunded by dollar amount without a refunded quantity, and send order total/tax net of refunds. 163 161 164 = 5.1.12 = 162 165 > Auto labels are now created in the background after checkout, so shoppers no longer wait for the label at checkout. -
a2z-fedex-shipping/trunk/a2zfedex_basic.php
r3793984 r3844131 4 4 * Plugin URI: https://myshipi.com/ 5 5 * Description: Realtime Shipping Rates, shipping labels. 6 * Version: 5.1.1 26 * Version: 5.1.13 7 7 * Author: Shipi 8 8 * Author URI: https://myshipi.com/ … … 2242 2242 } 2243 2243 2244 $net_totals = $this->shipi_get_net_order_totals($order, $order_data); 2244 2245 $data = array(); 2245 2246 $data['integrated_key'] = $general_settings['hitshippo_fedex_shippo_int_key']; … … 2317 2318 "inv_letterhead" => isset($general_settings['hitshippo_fedex_inv_letterhead']) ? $general_settings['hitshippo_fedex_inv_letterhead'] : '', 2318 2319 "ship_price" => $shipping_charge, 2319 "other_charges" => apply_filters("shipi_fedex_other_charges", (isset($order_data["total_tax"]) && $order_data["total_tax"] > 0 ? $order_data["total_tax"] : 0), $order_data),2320 "order_total" => isset($order_data['total']) ? $order_data['total'] : 0,2320 "other_charges" => apply_filters("shipi_fedex_other_charges", $net_totals['total_tax'], $order_data), 2321 "order_total" => $net_totals['total'], 2321 2322 "custom" => apply_filters("shipi_fedex_custom_values", array(), $_POST), 2322 "order_total_tax" => isset($order_data['total_tax']) ? $order_data['total_tax'] : 0,2323 "order_total_tax" => $net_totals['total_tax'], 2323 2324 ); 2324 2325 … … 3089 3090 // $order_shipping_email = $order_data['billing']['email']; 3090 3091 3091 $shipping_charge = $order_data['shipping_total']; 3092 $net_totals = $this->shipi_get_net_order_totals($order, $order_data); 3093 $shipping_charge = $net_totals['shipping_total']; 3092 3094 $handling_charge = (float) $order_data['discount_total']; 3093 3095 … … 3227 3229 "inv_letterhead" => isset($general_settings['hitshippo_fedex_inv_letterhead']) ? $general_settings['hitshippo_fedex_inv_letterhead'] : '', 3228 3230 "ship_price" => $shipping_charge, 3229 "other_charges" => apply_filters("shipi_fedex_other_charges", (isset($order_data["total_tax"]) && $order_data["total_tax"] > 0 ? $order_data["total_tax"] : 0), $order_data),3231 "other_charges" => apply_filters("shipi_fedex_other_charges", $net_totals['total_tax'], $order_data), 3230 3232 "handling_price" => ($handling_charge > 0 ? ((-1) * $handling_charge) : 0), 3231 3233 "ship_date" => isset($_POST["ship_date"]) ? $_POST["ship_date"] : "", 3232 "order_total" => isset($order_data['total']) ? $order_data['total'] : 0,3233 "order_total_tax" => isset($order_data['total_tax']) ? $order_data['total_tax'] : 0,3234 "order_total" => $net_totals['total'], 3235 "order_total_tax" => $net_totals['total_tax'], 3234 3236 "custom" => apply_filters("shipi_fedex_custom_values", array(), $_POST), 3235 3237 "label" => $create_shipment_for, … … 3285 3287 } 3286 3288 } 3289 /** 3290 * Return remaining quantity and line total after refunds, or false when an item is fully refunded. 3291 */ 3292 private function shipi_get_net_order_item($order, $item, $product_data) 3293 { 3294 $qty = isset($product_data['quantity']) ? (float) $product_data['quantity'] : 0.0; 3295 $refunded_qty = method_exists($order, 'get_qty_refunded_for_item') 3296 ? abs((float) $order->get_qty_refunded_for_item($item->get_id())) 3297 : 0.0; 3298 $remaining_qty = $qty - $refunded_qty; 3299 3300 if ($remaining_qty <= 0) { 3301 return false; 3302 } 3303 3304 $line_total = isset($product_data['total']) ? (float) $product_data['total'] : 0.0; 3305 $refunded_total = method_exists($order, 'get_total_refunded_for_item') 3306 ? abs((float) $order->get_total_refunded_for_item($item->get_id())) 3307 : 0.0; 3308 $remaining_total = $line_total - $refunded_total; 3309 3310 // Exclude items refunded by dollar amount without a refunded quantity; keep unrefunded $0 promo items. 3311 if ($line_total > 0 && round($remaining_total, 2) <= 0) { 3312 return false; 3313 } 3314 3315 return array( 3316 'remaining_qty' => $remaining_qty, 3317 'remaining_total' => $remaining_total, 3318 ); 3319 } 3320 3321 /** 3322 * Return order total, tax, and shipping net of WooCommerce refunds. 3323 */ 3324 private function shipi_get_net_order_totals($order, $order_data) 3325 { 3326 $total = isset($order_data['total']) ? (float) $order_data['total'] : 0.0; 3327 $tax = isset($order_data['total_tax']) ? (float) $order_data['total_tax'] : 0.0; 3328 $shipping = isset($order_data['shipping_total']) ? (float) $order_data['shipping_total'] : 0.0; 3329 3330 if (method_exists($order, 'get_total_refunded')) { 3331 $total = max(0.0, round($total - abs((float) $order->get_total_refunded()), 2)); 3332 } 3333 if (method_exists($order, 'get_total_tax_refunded')) { 3334 $tax = max(0.0, round($tax - abs((float) $order->get_total_tax_refunded()), 2)); 3335 } 3336 if (method_exists($order, 'get_total_shipping_refunded')) { 3337 $shipping = max(0.0, round($shipping - abs((float) $order->get_total_shipping_refunded()), 2)); 3338 } 3339 3340 return array( 3341 'total' => $total, 3342 'total_tax' => $tax, 3343 'shipping_total' => $shipping, 3344 ); 3345 } 3346 3287 3347 private function get_products_on_order($general_settings = [], $order = []) 3288 3348 { … … 3298 3358 $product_data = $item->get_data(); 3299 3359 3300 $refunded_qty = $order->get_qty_refunded_for_item( $item->get_id() ); 3301 $remaining_qty = $product_data['quantity'] - abs($refunded_qty); 3302 3303 if ($remaining_qty <= 0) { 3360 $net_item = $this->shipi_get_net_order_item($order, $item, $product_data); 3361 if ($net_item === false) { 3304 3362 continue; 3305 3363 } 3364 $remaining_qty = $net_item['remaining_qty']; 3365 $remaining_total = $net_item['remaining_total']; 3306 3366 3307 3367 $product = array(); … … 3344 3404 } 3345 3405 $product['product_name'] = apply_filters("shipi_product_name_change", str_replace('"', '', $getproduct->get_name()), $getproduct->get_id()); 3346 $refunded_total = $order->get_total_refunded_for_item( $item->get_id() ); 3347 $remaining_total = $product_data['total'] - abs($refunded_total); 3348 $product['price'] = (isset($remaining_total) && $remaining_total > 0) ? round($remaining_total/$remaining_qty, 2): $getproduct->get_price(); 3406 $product['price'] = ($remaining_total > 0) ? round($remaining_total/$remaining_qty, 2) : $getproduct->get_price(); 3349 3407 $product['width'] = (!empty($getproduct->get_width())) ? round(wc_get_dimension($getproduct->get_width(),$mod_dim_unit,$woo_dim_unit)) : ''; 3350 3408 $product['height'] = (!empty($getproduct->get_height())) ? round(wc_get_dimension($getproduct->get_height(),$mod_dim_unit,$woo_dim_unit)) : ''; -
a2z-fedex-shipping/trunk/readme.txt
r3793984 r3844131 5 5 Tested up to: 7.0 6 6 Requires PHP: 5.6 7 Stable tag: 5.1.1 27 Stable tag: 5.1.13 8 8 License: GPLv3 or later License 9 9 URI: http://www.gnu.org/licenses/gpl-3.0.html … … 159 159 160 160 == Changelog == 161 = 5.1.13 = 162 * Fixed: Exclude items refunded by dollar amount without a refunded quantity, and send order total/tax net of refunds. 163 161 164 = 5.1.12 = 162 165 > Auto labels are now created in the background after checkout, so shoppers no longer wait for the label at checkout.
Note:
See TracChangeset
for help on using the changeset viewer.