本文整理汇总了PHP中Base::asApiArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Base::asApiArray方法的具体用法?PHP Base::asApiArray怎么用?PHP Base::asApiArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base
的用法示例。
在下文中一共展示了Base::asApiArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: asApiArray
public function asApiArray($args = array())
{
$attributes = parent::asApiArray();
if (isset($attributes['metadata'])) {
$upload_dir = wp_get_attachment_image_src($this->_actual_model_id, 'full');
$md = $attributes['metadata'];
if (!is_array($md)) {
$md = array();
}
$md['url'] = $upload_dir[0];
$attributes['metadata'] = $md;
if (isset($attributes['metadata']['sizes']) && is_array($attributes['metadata']['sizes'])) {
foreach ($attributes['metadata']['sizes'] as $key => &$md) {
// $upload_dir = wp_get_attachment_image_src( $this->_actual_model_id, $key);
// $md['url'] = $upload_dir[0];
$medium_array = image_downsize($this->_actual_model_id, $key);
$md['url'] = $medium_array[0];
if (isset($md['get_attachment_metadata is'])) {
unset($md['get_attachment_metadata is']);
}
if (isset($md['array is'])) {
unset($md['array is']);
}
//$md['array is'] = $medium_array;
//$md['get_attachment_metadata is'] = wp_get_attachment_metadata($this->_actual_model_id);
}
}
}
return $attributes;
}
示例2: asApiArray
public function asApiArray($args = array())
{
$attrs = parent::asApiArray();
$attrs['order_items'] = $this->order_items;
$attrs['notes'] = $this->notes;
$attrs['tax_items'] = $this->tax_items;
$attrs['coupon_items'] = $this->coupon_items;
return $attrs;
}
示例3: asApiArray
public function asApiArray($args = array())
{
$attributes_to_send = parent::asApiArray();
$attributes_to_send['metadata'] = get_metadata('order_item', $this->_actual_model_id, '', false);
foreach ($attributes_to_send['metadata'] as $key => &$value) {
$value = $value[0];
}
if (isset($attributes_to_send['metadata']['_variation_id']) && !empty($attributes_to_send['metadata']['_variation_id'])) {
$pid = $attributes_to_send['metadata']['_variation_id'];
} else {
if (isset($attributes_to_send['metadata']['_product_id'])) {
$pid = $attributes_to_send['metadata']['_product_id'];
}
}
if (isset($pid)) {
$product = Product::find($pid);
if ($product->isValid()) {
$attributes_to_send['product'] = $product->asApiArray();
} else {
$attributes_to_send['product'] = null;
}
}
return $attributes_to_send;
}
示例4: asApiArray
public function asApiArray($args = array())
{
include WCAPIDIR . "/_globals.php";
$attributes_to_send = parent::asApiArray($args);
if (!isset($args['include']) || !is_array($args['include'])) {
$args['include'] = array();
}
foreach (array('categories', 'tags', 'reviews', 'variations', 'images', 'featured_image') as $assoc) {
if (!isset($args['include'][$assoc])) {
$args['include'][$assoc] = true;
}
if ($args['include'][$assoc] == true) {
$attributes_to_send[$assoc] = $this->{$assoc};
}
}
if ($attributes_to_send['type'] == 'product_variation' && empty($attributes_to_send['featured_image'])) {
$parent_product = Product::find($attributes_to_send['parent_id']);
if ($parent_product->isValid()) {
$attributes_to_send['featured_image'] = $parent_product->featured_image;
}
}
// $attributes_to_send['categories'] = $this->categories;
// $attributes_to_send['tags'] = $this->tags;//wp_get_post_terms($this->_actual_model_id,'product_tag');
// $attributes_to_send['reviews'] = $this->reviews;
// $attributes_to_send['variations'] = $this->variations;
// $attributes_to_send['images'] = $this->images;
// $attributes_to_send['featured_image'] = $this->featured_image;
if (is_array($attributes_to_send['attributes'])) {
$has_string_keys = false;
foreach ($attributes_to_send['attributes'] as $k => $v) {
if (is_string($k)) {
$has_string_keys = true;
break;
}
}
if (!$has_string_keys) {
$attributes_to_send['attributes'] = new \stdClass();
}
} else {
if (is_string($attributes_to_send['attributes'])) {
$attributes_to_send['attributes'] = new \stdClass();
}
}
return $attributes_to_send;
}