복붙노트

[WORDPRESS] 전체 및 납세자의 woocommerce를 변경하십시오

WORDPRESS

전체 및 납세자의 woocommerce를 변경하십시오

해결법


  1. 1.사용하려고합니다

    사용하려고합니다

    add_action('woocommerce_calculate_totals', array($this, 'calculate_totals'), 10, 1);
    
    function calculate_totals($totals){
    //your code
    }
    

    또한 장바구니 객체에서 세금 총액이어야하며 변경할 수 있습니다.


  2. 2.나는 다른 솔루션을 얻는 데 문제가 있었지만 적어도 V.3.0.1의 경우, 이것은 훌륭한 일을했습니다.

    나는 다른 솔루션을 얻는 데 문제가 있었지만 적어도 V.3.0.1의 경우, 이것은 훌륭한 일을했습니다.

    add_action('woocommerce_cart_total', 'calculate_totals', 10, 1);
    
    function calculate_totals($wc_price){
        $new_total = 0;
        foreach ( WC()->cart->cart_contents as $key => $value ) {
            //calculations here
        }
    
        return wc_price($new_total);
    }
    
  3. from https://stackoverflow.com/questions/32872057/change-total-and-tax-total-woocommerce by cc-by-sa and MIT license