mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/65401375/change-programmatically-woocommerce-cart-items-from-virtual-to-physical/65401807
10 lines
369 B
Text
10 lines
369 B
Text
add_action( 'woocommerce_before_calculate_totals', 'custom_cart_item_data_replacement', 16 );
|
|
function custom_cart_item_data_replacement( $cart ) {
|
|
|
|
foreach ( $cart->get_cart() as $cart_item ) {
|
|
// Change virtual cart item to "physical"
|
|
if( $cart_item['data']->get_virtual() ) {
|
|
$cart_item['data']->set_virtual(false);
|
|
}
|
|
}
|
|
}
|