-1

hi i get some error from wp. log is

Notice: id was called incorrectly. Product properties should not be accessed directly

https://wordpress.org/support/topic/product-properties-should-not-be-accessed-directly-2/

so i tried with reference to the corresponding url.

change code $product->get_name();

It was changed to the above code and operated normally. But after yesterday's Woocommerce update, the code no longer worked.

Does anyone have a good idea?

Kt H
  • 87
  • 1
  • 10
  • 1
    Sorry but [`WC_Product` `get_name()`](https://github.com/woocommerce/woocommerce/blob/master/includes/abstracts/abstract-wc-product.php#L151-L160) method is correct and exist… **The method `get_title()` is just an alias of `get_name()` method** … see here [the source code of `get_title()` method](https://github.com/woocommerce/woocommerce/blob/master/includes/abstracts/abstract-wc-product.php#L1697-L1704) … The *"ID called incorrectly"* is about using `$product->get_id()` instead of `$product->id`… – LoicTheAztec Mar 27 '19 at 03:06

1 Answers1

2

i resolved.

echo esc_attr($product->get_title());

I hope it will help someone.

Kt H
  • 87
  • 1
  • 10
  • Sorry but [`WC_Product` `get_name()`](https://github.com/woocommerce/woocommerce/blob/master/includes/abstracts/abstract-wc-product.php#L151-L160) method is correct and exist… So that has nothing to do with accessing product properties as here it's about methods that exist and are allowed… **The method `get_title()` is just an alias of `get_name()` method** … see here [the source code of `get_title()` method](https://github.com/woocommerce/woocommerce/blob/master/includes/abstracts/abstract-wc-product.php#L1697-L1704) – LoicTheAztec Mar 27 '19 at 03:06