Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter enoch008

    (@enoch008)

    Is this plugin abandoned?

    Thread Starter enoch008

    (@enoch008)

    For those who have the same need I have solved this way:

    I added a new hook in the custom template to show what i ned in the right position (in my case under the total amount) like this:

    <?php do_action( 'wpo_wcpdf_after_total_price', $this->get_type(), $this->order ); ?>

    And i added this to function.php:

    add_action( 'wpo_wcpdf_after_total_price', 'wpo_wcpdf_meta3', 10, 2 );
    function wpo_wcpdf_meta3( $template_type, $order ) {
      $user = $order->get_user();
    
    if ( in_array( 'convenzionato', (array) $user->roles ) ){
      
      ?> 
      <tr class="sconto">
                                    <th class="description">Sconto convenzione</th>
                                    <td class="price"><span class="totals-price"><?php echo $order->get_meta('_sconto_convenzione'); ?></span></td>
                                </tr>
                                <?php
    }
    }

    Thanks so much Yordan for helping me, maybe you can edit the post title to help other users.

    Thread Starter enoch008

    (@enoch008)

    The user role is certainly correct, its a custom user role named convenzionato. Its certainly correct cause i used it in other functions.
    That’s the part of the template that i try to edit:

    <td class="no-borders" colspan="2">
    	<table class="totals">
    	<tfoot>
    		<?php foreach ( $this->get_woocommerce_totals() as $key => $total ) : ?>
    		<tr class="<?php echo $key; ?>">
    			<th class="description"><?php echo $total['label']; ?></th>
    			<td class="price"><span class="totals-price"><?php echo $total['value']; ?></span></td>
    		</tr>
    		<?php endforeach; ?>
    		<?php
    		$user = $order->get_user();
    		if ( in_array( 'convenzionato', (array) $user->roles ) ) {
    		<tr class="sconto">
    		<th class="description">Sconto convenzione</th>
    		<td class="price"><span class="totals-price"><?php echo $order->get_meta('_sconto_convenzione'); ?></span></td>
    		</tr>							
    }
    ?>
    	</tfoot>
    	</table>
    </td>
    Thread Starter enoch008

    (@enoch008)

    Thanks!
    I tried adding this to the custom template but it doesnt work.

    <?php
    $user = $order->get_user();
    if ( in_array( 'customer', (array) $user->roles ) ) {
    	<tr class="sconto">
    		<th class="description">Sconto convenzione</th>
    		<td class="price"><span class="totals-price"><?php echo $order->get_meta('_sconto_convenzione'); ?></span></td>
    	</tr>
    							
    }
    ?>

    Please translate also the coupon phrase.

    Thread Starter enoch008

    (@enoch008)

    Hi, thanks for taking the time to respond to me.
    I added the following code to the custom template that I’ve created.

    <tr class="sconto">
    								<th class="description">Sconto convenzione</th>
    								<td class="price"><span class="totals-price"><?php echo $order->get_meta('_sconto_convenzione'); ?></span></td>
    							</tr>
    

    It works, but is there a way to display it based on user role?

    • This reply was modified 4 years, 1 month ago by enoch008.
Viewing 6 replies - 1 through 6 (of 6 total)