Forum Replies Created

Viewing 1 replies (of 1 total)
  • Forum: Plugins
    In reply to: Custom data to Webhook

    Hello Andre,

    If you can query the product ID, then query the post_author for the products post ID. That’s the vendor. From there, the world is yours!

    function my_custom_orders_api_fields($payload) {
    
    $post = $order->id;
    
    $items = $order->get_items();
    foreach ( $items as $item ) {
    $product_id = $item['product_id'];
    }
    
    $vendor_id = get_post_field( 'post_author', $product_id );
    
    $shop_name = get_user_meta( $vendor_id, ‘pv_shop_name’, true );
    
    $payload[‘loja’][‘nome’] = $shop_name;
    
    return $payload;
    }
    
    add_filter( ‘woocommerce_api_order_response’, ‘my_custom_orders_api_fields’,
Viewing 1 replies (of 1 total)