post_type || 'shop_order_placehold' === $post->post_type) { $order = wc_get_order($post->ID); } elseif ( ('order-products' === $this->maker->type || ('orders' === $this->maker->type && in_array($post->post_type, array('product', 'product_variation'))) ) && isset($post->orderId) ) { $order = wc_get_order($post->orderId); } else { $order = null; } return $order; } protected function getOrderItemMetaField($post, $field) { try { if (!property_exists($post, 'orderItem')) { return ''; } if (metadata_exists('order_item', $post->orderItem->get_id(), $field['value'])) { $value = get_metadata('order_item', $post->orderItem->get_id(), $field['value'], true); } return !empty($value) ? $value : ''; } catch (\Exception $e) { return ''; } } protected function getAttributesOptions($parentNotVariableAttributes) { $attributesOptions = array(); foreach ($parentNotVariableAttributes as $parentNotVariableAttribute) { if ($parentNotVariableAttribute->is_taxonomy()) { $attributesOptions[] = array( 'label' => $parentNotVariableAttribute->get_taxonomy_object()->attribute_label, 'options' => wp_list_pluck($parentNotVariableAttribute->get_terms(), 'name'), ); } else { $attributesOptions[] = array( 'label' => $parentNotVariableAttribute->get_name(), 'options' => $parentNotVariableAttribute->get_options(), ); } } return $attributesOptions; } }