• There is a critical error caused by the plugin when trying to update products which is hindering many businesses. For some reason, on product update, the plugin uses the wc_get_order function to try to update the product meta for the Share A Sale category and subcategory. The wc_get_order function is returning bool and then the plugin is trying to update meta on bool. That is why users are experiencing PHP fatal errors. Fix provided below (see Replace entirely with).

    Plugin file:
    shareasale-wc-tracker/admin/class-shareasale-wc-tracker-admin.php

    Current function starting on line 246:

    public function woocommerce_process_product_meta( $post_id ) { ? ? ? ?
    
    ? ? //woocommerce_save_data nonce already safely checked by now
    
    ? ? if ( ! empty( $_POST['shareasale_wc_tracker_datafeed_product_category'] ) ) {
    
    ? ? ? ? $order = wc_get_order( $post_id );
    
    ? ? ? ? if ( $order ) {
    
    ? ? ? ? ? ? $order->update_meta_data( 'shareasale_wc_tracker_datafeed_product_category', sanitize_text_field( $_POST['shareasale_wc_tracker_datafeed_product_category'] ) );
    
    ? ? ? ? ? ? $order->save();
    
    ? ? ? ? }
    
    ? ? }
    
    ? ? if ( ! empty( $_POST['shareasale_wc_tracker_datafeed_product_subcategory'] ) ) {
    
    ? ? ? ? $order = wc_get_order( $post_id );
    
    ? ? ? ? if ( $order ) {
    
    ? ? ? ? ? ? $order->update_meta_data( 'shareasale_wc_tracker_datafeed_product_subcategory', sanitize_text_field( $_POST['shareasale_wc_tracker_datafeed_product_subcategory'] ) );
    
    ? ? ? ? ? ? $order->save();
    
    ? ? ? ? }
    
    ? ? }
    
    }

    Replace entirely with:

    public function woocommerce_process_product_meta( $post_id ) { ? ? ? ?
    
    ? ? //woocommerce_save_data nonce already safely checked by now
    
    ? ? if ( ! empty( $_POST['shareasale_wc_tracker_datafeed_product_category'] ) ) {
    
    ? ? ? ? $product = wc_get_product( $post_id );
    
    ? ? ? ? if ( $product ) {
    
    ? ? ? ? ? ? $product->update_meta_data( 'shareasale_wc_tracker_datafeed_product_category', sanitize_text_field( $_POST['shareasale_wc_tracker_datafeed_product_category'] ) );
    
    ? ? ? ? ? ? $product->save();
    
    ? ? ? ? }
    
    ? ? }
    
    ? ? if ( ! empty( $_POST['shareasale_wc_tracker_datafeed_product_subcategory'] ) ) {
    
    ? ? ? ? $product = wc_get_product( $post_id );
    
    ? ? ? ? if ( $product ) {
    
    ? ? ? ? ? ? $product->update_meta_data( 'shareasale_wc_tracker_datafeed_product_subcategory', sanitize_text_field( $_POST['shareasale_wc_tracker_datafeed_product_subcategory'] ) );
    
    ? ? ? ? ? ? $product->save();
    
    ? ? ? ? }
    
    ? ? }
    
    }

    The page I need help with: [log in to see the link]

  • The topic ‘*FIX PROVIDED* PHP Uncaught Error: Call to a member function update_meta_data()’ is closed to new replies.