Render custom post type custom field - Woocommerce

Support MB Builder Render custom post type custom field - WoocommerceResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #36876
    EliodataEliodata
    Participant

    Hi,
    I would like a meta box to let user choose from Woocommerce orders. I use the advanced custom field "post" and select the "shop_order" type. But impossible to see any Woocommerce order in the select box (empty).
    it works normally for the other custom post types.
    regards

    #36892
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Because the post type shop_order is not publicly to query, you can see here https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes/class-wc-post-types.php#L387-L426
    You can try to use the filter woocommerce_register_post_type_shop_order to override this default setting of WooCommerce.

    #36894
    EliodataEliodata
    Participant

    Hello,
    Thank you for the quick answer!

    I tried two snippets:

    
    add_action('init', 'wc_orders_public');
    function wc_orders_public() {
            global $wp_post_types;
            $wp_post_types['shop_order']->public = true;
    }
    

    and:

    
    add_action('init', 'wc_orders_public');
    function wc_orders_public() {
            global $wp_post_types;
            $wp_post_types['shop_order']->public = true;
            $wp_post_types['shop_order']->publicly_queryable = true;
            $wp_post_types['shop_order']->exclude_from_search = false;
            $wp_post_types['shop_order']->rewrite = true;
            $wp_post_types['shop_order']->query_var = 'shop_order';
    }
    

    But still doesn't work.

    Regards

    #37008
    EliodataEliodata
    Participant

    I have the same issue using relationships addon. I tried bidirectionnal relationship between CPT and shop_order but still can't see order in the metabox select field.

    I installed posts 2 posts plugin (by scribu) with the same settings and it works. But I don't want to use another plugin. And I the relationship to work with admin column plugin, as metabox.io does.

    Do you have an idea to make this work please?

    #37025
    Long NguyenLong Nguyen
    Moderator

    Hi,

    I'm trying to investigate the issue and get back to you later. Thanks for your patience.

    #37313
    EliodataEliodata
    Participant

    Hi,
    Thank you for the support. Could you find the solution?
    Regards

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.