• Resolved tomi500

    (@tomi500)


    Hello!

    The $heading variable text (default ‘Your license key(s)’) appears in the order details and in the email even if no licensed product is present in the order.
    Probably there is a more elegant solution to solve the problem, but the one I was using was to change the template files as shown below.
    The indent has not been modified to keep the minimum difference from the original shape.

    1. order-view-license-keys.php.patch content is:

    diff U3Bb license-manager-for-woocommerce/templates/order-view-license-keys.php trunk/templates/order-view-license-keys.php
    --- license-manager-for-woocommerce/templates/order-view-license-keys.php	Tue May  7 18:32:27 2019
    +++ trunk/templates/order-view-license-keys.php	Tue May  7 18:50:31 2019
    @@ -1,5 +1,15 @@
     <?php defined('ABSPATH') || exit; ?>
     
    +<?php $counter = 0;
    +foreach ( $data as $product_id => $row ) {
    +	foreach ( $row['keys'] as $entry ) {
    +		if ( $entry->license_key ) {
    +			$counter = $counter + 1;
    +		}
    +	}
    +} ?>
    +
    +<?php if ( $counter ): ?>
     <h2><?php esc_html_e($heading);?></h2>
     
     <?php foreach ($data as $product_id => $row): ?>
    @@ -28,4 +38,4 @@
             </tbody>
         </table>
     <?php endforeach; ?>
    -
    +<?php endif; ?>

    2. email-order-license-keys.patch content is:

    diff U3Bb license-manager-for-woocommerce/templates/emails/email-order-license-keys.php trunk/templates/emails/email-order-license-keys.php
    --- license-manager-for-woocommerce/templates/emails/email-order-license-keys.php	Tue May  7 18:32:28 2019
    +++ trunk/templates/emails/email-order-license-keys.php	Tue May  7 20:14:38 2019
    @@ -1,5 +1,15 @@
     <?php defined('ABSPATH') || exit; ?>
     
    +<?php $counter = 0;
    +foreach ( $data as $product_id => $row ) {
    +	foreach ( $row['keys'] as $entry ) {
    +		if ( $entry->license_key ) {
    +			$counter = $counter + 1;
    +		}
    +	}
    +} ?>
    +
    +<?php if ( $counter ): ?>
     <h2><?php esc_html_e($heading);?></h2>
     
     <div style="margin-bottom: 40px;">
    @@ -33,3 +43,4 @@
             </table>
         <?php endforeach; ?>
     </div>
    +<?php endif; ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter tomi500

    (@tomi500)

    P.S.

    It looks better if a </br> is added before the last <?php endif; ?> in the order-view-license-keys.php template

    Hello @tomi500,

    thank you for letting me know, good catch. I will fix this as soon as I get back from vacation (May 13).

    PS: If you need any additional functionality please let me know.

    Regards,
    Dra?en

    Thread Starter tomi500

    (@tomi500)

    Hello Dra?en,

    Thank you!

    The plugin perfectly covers my needs for selling refill codes for telephony services. Eventually, having chunks of different lengths would be the only thing I can think of now.

    I wish you good fun! Regards,
    Tomi

    Sounds to me like a perfectly reasonable use case. I will add this feature to the backlog and implement it.

    Hello @tomi500,

    I fixed this issue in the current development version. The fix will be included in the coming update.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Order and in the email issues if no licensed product is present in the order.’ is closed to new replies.