There is such an array, how to take a list of options from it(these are ID options of the attribute"pa_% d1% 86% d0% b2% d0% b5% d1% 82"), and output for each option value and additional custom fields?

   [pa_% d1% 86% d0% b2% d0% b5% d1% 82]=>WC_Product_Attribute Object
           [data: protected]=>Array



  • Wrap the code in the code section and select php there, or else your eyes hurt to read) – Kung-fu Mind May 5 '19 at 21:52
  • Kung-fu Mind, wrapped, you can look at the Inspector) I apologize :) – Dr.100 May 5 '19 at 21:58
  • Dr.100, it is strange that the brackets were removed in this way) In general, the answer is below, how to apply it in your case - see the situation – Kung-fu Mind May 5 '19 at 22:04
  • Kung-fu Mind, I have a problem not with access to data, but with writing the correct call.I want to get something like $result=array($array[options]).I don’t understand how to do this. – Dr.100 May 5 '19 at 22:13

2 Answers 2
  • There are no problems with data protection, I generally do not know how to select a plug in a complex hierarchy.Tell me how to take all the[options] keys into a new array – Dr.100 May 5 '19 at 22:07
  • From the array, the key is obtained by the name of the variable and the name of the key in square brackets, such as: $var['key']
    From the object, the key is obtained through an arrow and the name of the field of the object, such as: $obj->field.
    In your case, there is an array in which, according to the key pa_% d1% 86% d0% b2% d0% b5% d1% 82, there is an object in which there is a data field, inside this field, the array again looks like this:
    $arr['pa _.......'] ->data['options'], in theory, we get an array of options.The php is not strong, honestly, I’m confused only by the protected field, but it should work.
    – Kung-fu Mind May 6 '19 at 00:35
You have printed the contents of the object
To display its data, see the documentationor the file with description of the class.

In the answer above, you were given a link to the forum page where you are offered to write a child class.If you have gone this way, then be sure to learn the parent class.So the way is correct, only a workaround.

In the tags to the question it was necessary to register the woocommerce tag