Fixing the WC_Abstract_Legacy_Order- __get Error in WooCommerce
Автор: vlogize
Загружено: 2025-09-26
Просмотров: 0
Описание:
Learn how to resolve the `WC_Abstract_Legacy_Order- __get, wc_doing_it_wrong` error in WooCommerce with simple code corrections and improved practices.
---
This video is based on the question https://stackoverflow.com/q/62978844/ asked by the user 'Demuri Celidze' ( https://stackoverflow.com/u/2119501/ ) and on the answer https://stackoverflow.com/a/62981467/ provided by the user 'LoicTheAztec' ( https://stackoverflow.com/u/3730754/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.
Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: "WC_Abstract_Legacy_Order- __get, wc_doing_it_wrong" WooCommerce error
Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l...
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license.
If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com.
---
Fixing the WC_Abstract_Legacy_Order->__get Error in WooCommerce
If you’ve encountered the error message "WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong" in your WooCommerce setup, you’re not alone. This specific problem usually arises due to changes in how WooCommerce handles order properties, especially during updates. In this post, we'll explore the causes of this error and provide you with a clear, step-by-step solution.
Understanding the Error
Starting from WooCommerce 3.0, direct access to object properties, such as $order->status or $order->total, has been deprecated. Instead, WooCommerce now provides methods to access these properties. This is what leads to the error message you’re seeing.
If you’re using an older coding style, it’s essential to adapt your code to align with these new standards to ensure compatibility and prevent errors.
Overview of the Original Function
Here's a brief recap of the original function where the error is occurring:
[[See Video to Reveal this Text or Code Snippet]]
Steps to Fix the Error
To rectify the issue and ensure your WooCommerce site runs smoothly, you need to replace direct property accesses with their corresponding methods. Here are the exact changes you need to make:
Change Order Status Check
Replace:
[[See Video to Reveal this Text or Code Snippet]]
With:
[[See Video to Reveal this Text or Code Snippet]]
Change Order Total Check
Replace:
[[See Video to Reveal this Text or Code Snippet]]
With:
[[See Video to Reveal this Text or Code Snippet]]
Updated Function
Here’s what your updated function should look like after implementing the necessary changes:
[[See Video to Reveal this Text or Code Snippet]]
Conclusion
Resolving the WC_Abstract_Legacy_Order->__get error in WooCommerce is relatively straightforward once you know where to look. By adapting to the updated property access methods like get_status() and get_total(), you can ensure your functions run without errors and conform to current coding standards.
If you continue to face issues, consider checking for other deprecated methods or functionalities in your code, especially after upgrading WooCommerce versions. Happy coding!
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: