php - woocommerce change price in checkout and cart page -


with woocommerce, in website i'd add in cart page select input user can select value between 2 options, , depending on value change price.

so far, total , change using :

function action_woocommerce_before_cart_totals(  ) {   global $woocommerce;   $woocommerce->cart->total  = $woocommerce->cart->total*0.25;    var_dump( $woocommerce->cart->total);};  

the issue when go checkout page doesn't take total calculated in functions.php

thanks helping me.

you can use woocommerce_review_order_before_order_total hook @ same time, display custom price in checkout, way:

add_action( 'woocommerce_review_order_before_order_total', 'custom_cart_total' ); add_action( 'woocommerce_before_cart_totals', 'custom_cart_total' ); function custom_cart_total() {      if ( is_admin() && ! defined( 'doing_ajax' ) )             return;      wc()->cart->total *= 0.25;     //var_dump( wc()->cart->total); } 

the code goes in function.php file of active child theme (or theme) or in plugin file.

this code tested , works.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -