F
F
Fqwd1232021-05-14 19:23:15
WooCommerce
Fqwd123, 2021-05-14 19:23:15

How to add custom fields to the order object?

I have some specific fields that I would like to store in the order - for example, the sum of all products without taking into account the discount (yes, I can just calculate this - but the order only stores the product id, and the price of the product may change). How can I do that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fqwd123, 2021-05-14
@Fqwd123

Found a way

add_action( 'woocommerce_checkout_update_order_meta', 'saving_checkout_cf_data');
function saving_checkout_cf_data( $order_id ) {
    update_post_meta( $order_id, ''ваше поле,  "значение"']);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question