Last active
February 12, 2017 14:25
-
-
Save anthonybudd/f63a228da4bc0975c765c2a4101ac3e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Class Product extends WP_Model | |
{ | |
... | |
public $virtual = [ | |
'humanWeight' | |
]; | |
public $serialize = [ | |
'humanWeight', | |
]; | |
public $protected = [ | |
'weight', | |
]; | |
public function _getHumanWeight() | |
{ | |
return $this->weight . 'Kg'; | |
} | |
} | |
$product = Product::find(15); | |
echo json_encode($product); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment