• Resolved MagusTSF

    (@magustsf)


    I am using a custom template to display products from specific categories in a table instead of the default layout. The table includes columns for the price of each variation.

    Since the update I am now seeing this error

    Notice: regular_price was called incorrectly. Product properties should not be accessed directly. Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /home/magus/web/members.magistercs.co.uk/public_html/wp-includes/functions.php on line 4137

    This is the code I am using to get the prices

    $available_variations = $product->get_available_variations();
    $my_prices = array();
    foreach ($available_variations as $variable_product) {
            $my_product = new WC_Product_Variation( $variable_product['variation_id']);
    	$my_prices[] = $my_product->regular_price;
    }

    What would be the new way of achieving this without the error?

    • This topic was modified 7 years, 7 months ago by MagusTSF.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Some light reading for you https://github.com/woocommerce/woocommerce/wiki/CRUD-Objects-in-3.0

    Swap out $my_product->regular_price; for $my_product->get_regular_price();

    Any idea how I would fix this issue: ?

    After updating woocommerce I get the following errors on my variable products, fairly new to all this, a ‘fix’ in layman’s terms would be awsome, Thank you.

    the exact error Im getting is :
    Notice: variation_id was called incorrectly. Product properties should not be accessed directly. Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /wp-includes/functions.php on line 4137

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Errors with variations and Custom template’ is closed to new replies.