I'm creating a custom plugin for my website.
In some part of this plugin I need to store extra meta in wp_postmeta
for each orders.
I added this in my plugin's class:
add_action ('woocommerce_before_checkout_process', array( &$this, 'add_item_meta', 10, 2) );
And this is add_item_meta()
function:
function add_item_meta( $item_id, $values ) {
wc_add_order_item_meta($item_id, '_has_event', 'yes' );
}
This function is not complete, but nothing happens with this codes; I think I need to use another hook but I can't find a proper one.
Does anyone know anything about this?
I also have another problem with $item_id
: this is woocommerce global variable but I can't see it in my plugin!
I mean I don't have access to this variable from my plugin or something like this!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…