Answer the question
In order to leave comments, you need to log in
Get added woocommerce order details?
Good day.
In the checkout cart (wordpress + woocommerce) I add a discount:
add_action('woocommerce_cart_calculate_fees' , 'add_custom_discount', 20, 1);
function add_custom_discount( WC_Cart $cart){
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
$percent = WC()->session->get( 'final_discount' );
if( $percent > 0 ){
$cart->add_fee( __('Скидка', 'woocommerce' ) , - $percent);
}
}
Answer the question
In order to leave comments, you need to log in
I found this data in $item[data:protected][total], but protected can only be obtained from a method... Who knows how?
global $woocommerce;
$wc_order = new WC_Order(26);
$items = $wc_order->get_fees();
foreach ($items as $item) {
// $item[data:protected][total];
echo "<pre>";
print_r($item);
echo "</pre>";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question