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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -