Order and in the email issues if no licensed product is present in the order.
-
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)
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.