A few key concepts are at the base of all WC_Data objects. Understanding how the class getsIn “getter” methods, manipulatesWith “setter” methods and stores dataWith “update” methods can provide insights into how you can set various classes to interact with custom data involved in your project. In this section we’ll look at:
The $data property is used to hold information that is fundamental to the representation of the class family. The $extra_data propertyPrimarily used by the product, order_item, and payment token families is used by descendants of the family to add data without overwriting the $data settings.
The WC_Meta_Data class helps ensure that WC_Data’s save_meta_data() method does not perform any unnecessary database writes.
* method is protected (only available when writing methods within descendants of WC_Data)
Now that you understand the difference between the different data types, and understand the methods at the core of WC_Data functionality, you can start to see the opportunities for easy customization.
In the next topic, we’ll look at how Data Stores are used provide a flexible method of database storage for WC_Data objects
But first, check your knowledge.
Hint: Be sure to look in blue boxes and at purple text “tooltips” for notes while you take the quiz.
0 of 4 Questions completed
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 4 Questions answered correctly
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Which data type has a special class to ensure database writes are minimized?
(T/F) WC_Data uses of a lot of “magic” methods.