Viewing 1 replies (of 1 total)
  • Plugin Author Saravana Kumar K

    (@mycholan)

    Hi

    You could use woocommerce_before_calculate_totals hook for this purpose, you can put something like this in your functions.php

    function calculate_cart_total( $cart_object ) {
        /* additional price that has to be added */
        $additionalPrice = 100;   
    
        foreach ( $cart_object->cart_contents as $key => $value ) {
            /* Check for the value ( or it could be any condition logic ) */
        	if( $value['wccpf_your_fields_name'] == "your expected value" ) {
                //change the price
                $quantity = floatval( $value['quantity'] );
                $orgPrice = floatval( $value['data']->price );
            	$value['data']->price = ( ( $orgPrice * $quantity ) + $additionalPrice );
            }
        }
    }
    add_action( 'woocommerce_before_calculate_totals', 'calculate_cart_total' );
Viewing 1 replies (of 1 total)
  • The topic ‘Change price based on customer choices’ is closed to new replies.