Place order = “Internal Server Error”
-
Hello ,
I have this code to display the subtotal item weight for cart and order items// Display the cart item weight in cart and checkout pages add_filter( 'woocommerce_get_item_data', 'display_custom_item_data', 10, 2 ); function display_custom_item_data( $cart_item_data, $cart_item ) { if ( $cart_item['data']->get_weight() > 0 ){ $cart_item_data[] = array( 'name' => __( 'Weight subtotal', 'woocommerce' ), 'value' => ( $cart_item['quantity'] * $cart_item['data']->get_weight() ) . ' ' . get_option('woocommerce_weight_unit') ); } return $cart_item_data; } // Save and Display the order item weight (everywhere) add_action( 'woocommerce_checkout_create_order_line_item', 'display_order_item_data', 20, 4 ); function display_order_item_data( $item, $cart_item_key, $values, $order ) { if ( $values['data']->get_weight() > 0 ){ $item->update_meta_data( __( 'Weight subtotal', 'woocommerce' ), ( $cart_item['quantity'] * $cart_item['data']->get_weight() ) . ' ' . get_option('woocommerce_weight_unit') ); } }
This work great in both cart-page and checkout-page when I click “Place order” I got an “Internal Server Error” something changed in woocommerce 3.8 or the code is deprecated.
I googled it and found so many codes, nothing works.
I can’t understand what’s wrong here.
Is there anyone who understands what’s going on herethe problematic part is here
// Save and Display the order item weight (everywhere) add_action( 'woocommerce_checkout_create_order_line_item', 'display_order_item_data', 20, 4 ); function display_order_item_data( $item, $cart_item_key, $values, $order ) { if ( $values['data']->get_weight() > 0 ){ $item->update_meta_data( __( 'Weight subtotal', 'woocommerce' ), ( $cart_item['quantity'] * $cart_item['data']->get_weight() ) . ' ' . get_option('woocommerce_weight_unit') ); } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Place order = “Internal Server Error”’ is closed to new replies.