Title: Tip Amount is miscalculated
Last modified: November 10, 2022

---

# Tip Amount is miscalculated

 *  [blu27](https://wordpress.org/support/users/blu27/)
 * (@blu27)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/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.

 * ![](https://ps.w.org/shipday-for-woocommerce/assets/icon-256x256.png?rev=2933456)
 * [Shipday Local Delivery for WooCommerce](https://wordpress.org/plugins/shipday-for-woocommerce/)
 * [Support Threads](https://wordpress.org/support/plugin/shipday-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/shipday-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shipday-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shipday-for-woocommerce/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [blu27](https://wordpress.org/support/users/blu27/)
 * Last activity: [3 years, 7 months ago](https://wordpress.org/support/topic/tip-amount-is-miscalculated/)
 * Status: not resolved