mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-03 12:12:25 +08:00
12 lines
597 B
Text
12 lines
597 B
Text
add_action( 'woocommerce_checkout_update_order_meta', 'wc_save_weight_order' );
|
|
|
|
function wc_save_weight_order( $order_id ) {
|
|
$weight = WC()->cart->get_cart_contents_weight();
|
|
update_post_meta( $order_id, '_cart_weight', $weight );
|
|
}
|
|
|
|
add_action( 'woocommerce_admin_order_data_after_billing_address', 'wc_delivery_weight_display_admin_order_meta', 10, 1 );
|
|
|
|
function wc_delivery_weight_display_admin_order_meta( $order ) {
|
|
echo '<p><strong>Order Weight:</strong> ' . get_post_meta( $order->get_id(), '_cart_weight', true ) . get_option( 'woocommerce_weight_unit' ) . '</p>';
|
|
}
|