Woocommerce – set total price before payment

I add a fee via php in review-order.php:

<?php   
    global $woocommerce;
    $total =  number_format($woocommerce->cart->total, 2, '.', ' ');

    $total = (float) number_format($total, 2, '.', ' ') + (float) number_format($vvk, 2, '.', ' ');
    $total = number_format($total, 2, ',', ' ');
?>

    <tr class="order-total">
        <th><?php _e( 'Total', 'woocommerce' ); ?></th>
        <td data-title="<?php _e( 'Total', 'woocommerce' ); ?>">
            <?php echo "<strong><span class="amount">€".$total."</span></strong>"; ?>
        </td>
    </tr>

Now i need to update the total price before payment.

Read More

Any ideas? Thanks.

Related posts

1 comment

  1. I am not sure I would do things that way – the next update will probably blow away your changes. Perhaps instead, add your fee using the fees API and add the code to your functions.php or relevant code file.

    In the example below, a 1% surcharge is added (you could easily modify this to suit your needs):

    add_action('woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
    function woocommerce_custom_surcharge() {
        global $woocommerce;
    
        if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;
    
        $percentage = 0.01;
        $surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;    
        $woocommerce->cart->add_fee( 'Surcharge', $surcharge, true, '' );
    
    }
    

    https://docs.woothemes.com/document/add-a-surcharge-to-cart-and-checkout-uses-fees-api/

Comments are closed.