vindi/vindi-woocommerce

View on GitHub
src/utils/CreditPaymentHelpers.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace VindiPaymentGateways;

class CreditHelpers
{

    public function get_cart_total($cart)
    {
        $total = $cart->total;
        $recurring = end($cart->recurring_carts);
        if (floatval($cart->total) == 0 && is_object($recurring)) {
            $total = $recurring->total;
        }
        foreach ($cart->get_fees() as $fee) {
            if ($fee->name == __('Juros', VINDI)) {
                $total -= $fee->amount;
            }
        }
        return $total;
    }
}