• Hi Support πŸ™‚

    Im trying to get the correct id of the supplier, to filter information in the email.

    The use case is that we do have 2 suppliers, 1 supplier needs to get billing adress fields, and not a shipping adress.

    While the other supplier, gets the shipping adress.

    Is there a way to do this? so i can separate logic pr. supplier mail? i was thinking something like this in my email template:

    Here i check for a specific slug, but it seems like that both of the slugs are present in both of the supplier emails send. So it will be returned true in both emails. Could you point me in a correct directions?


    $target_supplier_slug = 'Interglas'; // change supplier slug
    $supplier_found = false;

    if ( $order && is_object( $order ) ) {
    foreach ( $order->get_items() as $item ) {
    $product_id = $item->get_product_id();
    $suppliers = get_the_terms( $product_id, 'supplier' );
    if ( $suppliers && ! is_wp_error( $suppliers ) ) {
    foreach ( $suppliers as $supplier ) {
    if ( $supplier->slug === $target_supplier_slug ) {
    $supplier_found = true;
    break 2;
    }
    }
    }
    }
    }

    // Eks. hide supplier
    $extra_info = "";
    if ( ! $supplier_found ) { // Supplier found - Make output
    $extra_info = "<p style='margin:10px 0;text-align:left;'>" . __( "Her er ekstra information, da produkterne IKKE er fra den specifikke supplier.", "supplier-order-email" ) . "</p>";
    } else {
    // Alternative - Supplier is not the specified one.
    $extra_info = "<p style='margin:10px 0;text-align:left;'>" . __( "Produkterne er fra den specifikke supplier, og derfor vises denne besked.", "supplier-order-email" ) . "</p>";
    }

The topic ‘[Premium] Different custom fields depending supplier’ is closed to new replies.