Changing item meta after compeleted sale
-
Hi,
We want to be able to add a license code as an item meta after sale is complete. We currently have working code that does this but the issue is, it assigns a license to canceled/failed sales also instead of just completed sales. Can anyone provide tips as to how to fix up the code so that item meta is only updated and license code only assigned to completed sales?
Currently, this is the code that is being used:
add_action('woocommerce_add_order_item_meta', array($this, 'action_woocommerce_add_order_item_meta'), 10, 2); public function action_woocommerce_add_order_item_meta ($item_id, $values) { //print_r($the_order);die(); //iterate over all order items and assign a licence code //print_r($values); $licence = $this->_getProductLicenseCode((int)$values['product_id']); if( !$licence ) { return false; //wp_die('Error getting product licence code'); } woocommerce_add_order_item_meta($item_id, 'attribute_licence_code', $licence->licence_code); //change licence status $this->_setLicenceCodeStatus($licence->licence_id, 'assigned'); }
There is obviously more code involved than this, but this is the portion I was able to identify that fires the code assigning.
Help, please?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Changing item meta after compeleted sale’ is closed to new replies.