pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

WooCommerce Orders (shop_order post type) not showing up in Pods 'More Fields' #3594

Closed Fabrunet closed 8 years ago

Fabrunet commented 8 years ago

I created a 'Folder' pod, with a field 'Associated order' to display linked WooCommerce orders.

I extended the shop_order post type to add a Relationship field type, related to 'Folder'.

So 'Folders' and 'Orders' are now linked

Issue: when I edit a 'Folder', I can see the associated orders in the 'Custom fields' panel, but the 'More fields' is blank.


screeenshot2

screenshot3

screenshot

I have the latest versions of Wordpress (4.5.3), Pods (2.6.5.2) and WooCommerce (2.6.1). Local environnement, MAMP.

jimtrue commented 8 years ago

I think this has to do with Custom Statuses on posts not showing up in relationship fields, since Orders wouldn't exactly be 'published'.

Fabrunet commented 8 years ago

@jimtrue you were right. I manually edited the status for 'publish' in the database and the order is now showing up in relationship field.

Is there a simple way to force Pods to consider other post statuses?

ValmyRasp commented 8 years ago

Hi,

I have same version and i have also empy field list.

image

image

jimtrue commented 8 years ago

@Fabrunet Nope, there's not. That's why I figured this might be the issue. You confirmed my suspicions, so this will go straight to a bug/compatibility issue for handling. @sc0ttkclark This one sounds familiar (the need for managing multiple post statuses for relationship fields). Wasn't this similar to the #3451 issue?

JoryHogeveen commented 8 years ago

This filter should work for this:

pods_api_get_table_info_default_post_status

Example:

/**
 * Default Post Status to query for.
 *
 * Use to change "default" post status from publish to any other status or statuses.
 *
 * @param  array   $post_status  List of post statuses. Default is 'publish'
 * @param  string  $post_type    Post type of current object
 * @param  array   $info         Array of information about the object.
 * @param  string  $object       Type of object
 * @param  string  $name         Name of pod to load
 * @param  array   $pod          Array with Pod information. Result of PodsAPI::load_pod()
 * @param  array   $field        Array with field information
 *
 * @since unknown
 */
add_filter( pods_api_get_table_info_default_post_status, 'my_theme_get_table_info_default_post_status', 10, 8 );
function my_theme_get_table_info_default_post_status( $post_status, $post_type, $info, $object_type, $object, $name, $pod, $field ) {
    // (optional) filter by post type
    if ( $post_type == 'shop_order' ) {
        // Full list of WooCommerce post statusses: http://woocommerce.wp-a2z.org/oik_api/wc_get_order_statuses/
        $post_status[] = 'wc-completed';
    }
    return $post_status;
}

@sc0ttkclark Maybe add this to the field options UI? >> (https://codex.wordpress.org/Function_Reference/get_post_stati)

JoryHogeveen commented 8 years ago

Fixed in #3626