FIXED: This was only a duplication as I’ve updated my code to fix the deprecated code.
PROBLEM: During checkout, your plugin Woocommerce Custom Fields For Variation seems to be resulting in the following PHP error_log warning:
” woocommerce_add_order_item_meta is deprecated since version 3.0.0! Use woocommerce_new_order_item instead.”
…..
Here is a link with more info I used to debug & fix it >> https://stackoverflow.com/questions/49863814/trying-to-save-order-item-meta-data-with-woocommerce-new-order-item-hook
Modelled off the link above AND commented out the Plugin’s call to “woocommerce_add_order_item_meta” on line 26.
The details are below:
————————– ————————–
It is this file: “class-product-add-to-cart.php” line 26 I have changed to (by commenting it out):
// Add meta to order :: overwritten in functions.php with save_custom_order_item_meta_data)
//add_action( 'woocommerce_add_order_item_meta', 'phoen_order_item_var_meta' , 10, 2 );
I then added this code in my functions.php as a fix: (you may like to add it into your plugin code)
// Save custom data to order item meta data
add_action('woocommerce_checkout_create_order_line_item', 'save_custom_order_item_meta_data', 10, 4 );
function save_custom_order_item_meta_data( $item, $cart_item_key, $values, $order ) {
if( isset( $values['options'] ) ){
if( ! empty( $values['options'] ) ) {
foreach ( $values['options'] as $options ) {
$name = $options['name'];
if ( $options['price'] > 0 ) {
$name .= ' (' . wc_price( get_var_product_addition_options_price( $options['price'] ) ) . ')';
}
$item->update_meta_data( $name, $options['value'] );
}
}
}
}