• Resolved alexqbox

    (@alexqbox)


    Hello,

    i need to print the order total amount excl. taxes for a specific user role. The shop is seperated in a public shop and B2B shop. Only for the B2B customer i need that total excl. taxes.

    the user role is: b2b_kunde

    The Code i am using in the invoice.php is:

    <?php foreach ($taxes as $taxRate => $tax) : ?>
    <tr>
    <td class=”no-borders”></td>
    <th class=”description”>Nettobetrag <?php echo $taxRate; ?>%</th>
    <td class=”price”><span class=”totals-price”><?php echo number_format($tax, 2, “,”, “.”); ?> € (exkl. MwSt.)</span></td>
    </tr>
    <?php endforeach; ?>

    But that will print it for all customers. Is there a way to check for user role first?

    Thank you! Alex

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @alexqbox,

    Yes you can check for the user role(s) with the following logic:

    $user = $order->get_user();
    if ( $user && ( in_array( 'b2b_kunde', (array) $user->roles ) ) ) {
    	// Your code here...
    }
    Thread Starter alexqbox

    (@alexqbox)

    Hi @kluver thanks for your reply! If am using your Code i am getting just errors. How to combine my code above with your code correctly?

    Thanks in advance!

    Thread Starter alexqbox

    (@alexqbox)

    OK i got it sorted that way…

    $user = $order->get_user();
    if ( $user && ( in_array( ‘b2b_kunde’, (array) $user->roles ) ) ) {
    foreach ($taxes as $taxRate => $tax) {
    print ‘<tr>’;
    print ‘<td class=”no-borders”></td>’;
    print ‘<th class=”description”>Nettobetrag ‘ . $taxRate . ‘%</th>’;
    print ‘<td class=”price”><span class=”totals-price”>’ . number_format($tax, 2, “,”, “.”) . ‘ € (exkl. MwSt.)</span></td>’;
    print ‘</tr>’;
    }
    }

    • This reply was modified 3 years, 6 months ago by alexqbox.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Print Total excl. Taxes for specific user role in invoice’ is closed to new replies.