Support » Plugin: Cost of Goods for WooCommerce » Bug on product edit – exception

  • Resolved artipixel

    (@artipixel)


    On edit product page, after updating a cost value – the page raises an error.

    
    <b>Fatal error</b>:  Uncaught TypeError: Unsupported operand types: string * int in /home/customer/www/[deducted]/public_html/wp-content/plugins/woocommerce/includes/wc-formatting-functions.php:579
    Stack trace:
    #0 /home/customer/www/[deducted]/public_html/wp-content/plugins/cost-of-goods-for-woocommerce/includes/class-alg-wc-cog-products.php(439): wc_price('')
    #1 /home/customer/www/[deducted]/public_html/wp-content/plugins/cost-of-goods-for-woocommerce/includes/class-alg-wc-cog-products.php(384): Alg_WC_Cost_of_Goods_Products->get_variable_product_html(1837, 'profit', '%profit% (%prof...')
    #2 /home/customer/www/[deducted]/public_html/wp-content/plugins/cost-of-goods-for-woocommerce/includes/class-alg-wc-cog-products.php(470): Alg_WC_Cost_of_Goods_Products->get_product_profit_html(1837, '%profit% (%prof...')
    #3 /home/customer/www/[deducted]/public_html/wp-includes/class-wp-hook.php(287): Alg_WC_Cost_of_Goods_Products->add_cost_input('')
    #4 /home/customer/www/[deducted]/public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array)
    #5 /home/customer/www/[deducted]/public_html/wp-includes/plugin.php(484): WP_Hook->do_action(Array)
    #6 /home/customer/www/[deducted]/public_html/wp-content/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-general.php(71): do_action('woocommerce_pro...')
    #7 /home/customer/www/[deducted]/public_html/wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-product-data.php(42): include('/home/customer/...')
    #8 /home/customer/www/[deducted]/public_html/wp-content/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-panel.php(51): WC_Meta_Box_Product_Data::output_tabs()
    #9 /home/customer/www/[deducted]/public_html/wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-product-data.php(33): include('/home/customer/...')
    #10 /home/customer/www/[deducted]/public_html/wp-admin/includes/template.php(1389): WC_Meta_Box_Product_Data::output(Object(WP_Post), Array)
    #11 /home/customer/www/[deducted]/public_html/wp-admin/edit-form-advanced.php(688): do_meta_boxes(Object(WP_Screen), 'normal', Object(WP_Post))
    #12 /home/customer/www/[deducted]/public_html/wp-admin/post.php(206): require('/home/customer/...')
    #13 {main}
      thrown in <b>/home/customer/www/[deducted]/public_html/wp-content/plugins/woocommerce/includes/wc-formatting-functions.php</b> on line <b>579</b><br />

    It just breaks all JS functionality in the page and the product details will not show, as in here:
    https://pasteboard.co/JJ1SIpz.png

    • This topic was modified 5 months ago by artipixel.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter artipixel

    (@artipixel)

    I’ve found a temp fix:

    On the file –
    cost-of-goods-for-woocommerce/includes/class-alg-wc-cog-products.php

    In line 421,422-

    $min          = (float)current( $data );
    $max          = (float)end( $data );

    add to line 443:

    // temp fix start
    $cost = (float)$cost;
    $min = (float)$min;
    $price = (float)$price;
    // temp fix end	
    • This reply was modified 5 months ago by artipixel.
    • This reply was modified 5 months ago by artipixel.
    Plugin Author WP Factory

    (@wpcodefactory)

    Hello @artipixel ,

    I couldn’t reproduce the error, but I’ve added the (float) typecasting to these variables anyway, thanks.

    Plugin Author WP Factory

    (@wpcodefactory)

    I’m closing the ticket.
    Let me know if you still notice anything

    Thread Starter artipixel

    (@artipixel)

    All Seems fine now, Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.