/** * Add all fees at checkout. * * @access public */ public function add_fees() { foreach (WC()->cart->get_cart() as $cart_item => $values) { // Assume there is no fee. $fee = false; if (0 !== $values['variation_id']) { // Get variation fee. Will return false if there is no fee. $fee = new WCPF_Variation_Fee($values['product_id'], $values['quantity'], $values['data']->price, $values['variation_id']); } if (!$fee) { // Get product fee. Will return false if there is no fee. $fee = new WCPF_Product_Fee($values['product_id'], $values['quantity'], $values['data']->price); } if ($fee->return_fee()) { $data = $fee->return_fee(); do_action('wcpf_before_fee_is_added', $data); // Check if taxes need to be added. if (get_option('wcpf_fee_tax_class', '') !== '') { WC()->cart->add_fee($data['name'], $data['amount'], true, get_option('wcpf_fee_tax_class')); } else { WC()->cart->add_fee($data['name'], $data['amount'], false); } do_action('wcpf_after_fee_is_added', $data); } } }
/** * Return final fee data * * @access public */ public function return_fee() { $variation_fee_data = $this->get_variation_fee_data(); $fee_data = parent::quantity_multiply($variation_fee_data); return WCPF_Fee::get_fee($fee_data); }