Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter clickingclients

    (@clickingclients)

    1) You have not answered yet on here.
    2) You have no record of a changelog.

    3) I found the solution
    Previously I had located you plugin as throwing a note/warning in the errorlog.

    [19-Nov-2019 21:28:23 UTC] The woocommerce_add_order_item_meta function is deprecated since version 3.0. Replace with wc_add_order_item_meta.
    [19-Nov-2019 21:28:23 UTC] woocommerce_add_order_item_meta is deprecated since version 3.0.0! Use woocommerce_new_order_item instead.

    I got it fixed with this code: you may like to add it into yours for future releases.

    Modelled off the link below AND commented out the Plugin’s call to “woocommerce_add_order_item_meta” on line 26.
    https://stackoverflow.com/questions/49863814/trying-to-save-order-item-meta-data-with-woocommerce-new-order-item-hook

    
    // 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'] );
           }
    }
    }
    }I got it fixed with this code: you may like to add it into yours
    
    SOLVED: "woocommerce_add_order_item_meta"  warning.
    Culprit::  woo-custom-fields-for-variation
    Modelled off the link above AND commented out the Plugin's call to "woocommerce_add_order_item_meta" on line 26.
    
    // 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'] );
           }
    }
    }
    }
    Thread Starter clickingclients

    (@clickingclients)

    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'] );
                 }
             }
        }
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Latest update results in duplicate rows’ is closed to new replies.