skip to Main Content

I would like to change the total in the cart and checkout, multiplying it by 10. (because it currently shows me the 10% deposit price – Woocommerce Deposite plugin -, but I would like to display the total price without deposit).

So I thought about multiplying that by 10.

enter image description here

I’ve created a copy of the cart-totals.php in my child theme. And I would like to modify this string of code to display the price multiplied by 10.

<tr class="cart-subtotal">
            <th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
            <td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
        </tr>

So something like: <?php wc_cart_totals_subtotal_html(); ?> * 10 —-> 6100

Or if it’s simpler, I’d like to add up the prices of the products on the left: 1500+4600 —> 6100

How can I do that?

2

Answers


  1. Chosen as BEST ANSWER

    I added this code in my functions.php file, but nothing has changed.


  2. //calculator price
    function calculator_price( $price, $values ) {
    
        $new_price = $price *= 10;
        return $new_price;
    }
    
    add_filter( 'woocommerce_get_discounted_price', 'calculator_price', 10, 2 );
    
    // display new price
    function my_new_price( $values, $item ) {
     return wc_price( $item[ 'line_total' ] );
    }
    
    add_filter( 'woocommerce_cart_item_subtotal', 'my_new_price', 10, 2 );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search