mardi 30 décembre 2014

How to get private property in parent class into extended class?


I am not sure if my function is firing before another funciton or if I am having issues with the $this variable when I am extending my class.


I am creating a function in my functions.php file. Here's a link to my function.


The specific function is extending a class that is an extension for WooCommerce. The template page calls the function like so:



<?php
$ssi_woocommerce_variation_control_output = new SSi_WC_Swatch_Picker( $product->id, $attributes, $variation_params['selected_attributes'] );
print_r($ssi_woocommerce_variation_control_output);
$ssi_woocommerce_variation_control_output->picker();
?>


The print_r output will produce the array content to the page. However I get this:



Start the Loop

Notice: Undefined property: SSi_WC_Swatch_Picker::$attributes in /my_url/wp-content/themes/my-theme/functions.php on line 13

Warning: Invalid argument supplied for foreach() in /my_url/wp-content/themes/my-theme/functions.php on line 13

End the Loop




UPDATE Good news (at least for me) the developer of the original class is going to change the private properties to protected and then I can access them without issue.





Aucun commentaire:

Enregistrer un commentaire