Tip Amount is miscalculated
-
the tip amount passed in Shipday is done by this calculation
$tips = $total – $subtotal – $tax + $discount – $delivery_fee;
This may not be accurate, if you have other fees in your transaction. We used this to fix it in the plugin. Your fix may be different depending on the name of your Tip Fee in our case is “Tip Amount”
function get_costing(): array { $tax = $this->order->get_total_tax(); $discount = $this->order->get_total_discount(); $delivery_fee = $this->order->get_shipping_total(); $total = $this->order->get_total(); $subtotal = $this->order->get_subtotal(); //$tips = $total - $subtotal - $tax + $discount - $delivery_fee; // Iterating through order fee items ONLY foreach( $this->order->get_items('fee') as $item_id => $item_fee ){ // The fee name $fee_name = $item_fee->get_name(); /* Get the amount only if the fee is Tip Amount */ if( $fee_name == "Tip Amount" ){ // The fee total amount $tips = $item_fee->get_total(); break; } } return array( 'tips' => $tips, 'tax' => $tax, 'discountAmount' => $discount, 'deliveryFee' => $delivery_fee, 'totalOrderCost' => strval($total) ); }
- The topic ‘Tip Amount is miscalculated’ is closed to new replies.