- +
@@ -25,29 +27,29 @@- | - | - | + | + | + | + | %s', - esc_attr__( 'Unit price with discount including tax.', 'pronamic_ideal' ), - esc_html__( 'Unit Price', 'pronamic_ideal' ) + \esc_attr__( 'Unit price with discount including tax.', 'pronamic_ideal' ), + \esc_html__( 'Unit Price', 'pronamic_ideal' ) ); ?> | -+ | %s', - esc_attr__( 'Total discount.', 'pronamic_ideal' ), - esc_html__( 'Discount', 'pronamic_ideal' ) + \esc_attr__( 'Total discount.', 'pronamic_ideal' ), + \esc_html__( 'Discount', 'pronamic_ideal' ) ); ?> @@ -55,15 +57,15 @@ | %s', - esc_attr__( 'Total amount with discount including tax.', 'pronamic_ideal' ), - esc_html__( 'Total Amount', 'pronamic_ideal' ) + \esc_attr__( 'Total amount with discount including tax.', 'pronamic_ideal' ), + \esc_html__( 'Total Amount', 'pronamic_ideal' ) ); ?> | -+ | get_quantity(); - }, - $lines->get_array() - ); + $quantity_total = new Number( 0 ); - echo esc_html( array_sum( $quantities ) ); + foreach ( $lines as $line ) { + $quantity = $line->get_quantity(); + + if ( null !== $quantity ) { + $quantity_total = $quantity_total->add( Number::from_int( $quantity ) ); + } + } + + echo \esc_html( $quantity_total->format_i18n() ); ?> | get_discount_amount() ) { - return $line->get_discount_amount()->get_value(); - } + $discount_amount = $line->get_discount_amount(); + + return ( null === $discount_amount ) ? null : $discount_amount->get_value(); }, $lines->get_array() ); - $discount_amount = new Money( array_sum( $values ), $lines->get_amount()->get_currency() ); + $discount_amount = new Money( \array_sum( $values ), $lines->get_amount()->get_currency() ); - echo esc_html( $discount_amount ); + echo \esc_html( $discount_amount->format_i18n() ); ?> |
- get_total_amount()->get_excluding_tax()->get_value();
- },
- $lines->get_array()
- );
-
- $total_exclusive = new Money( array_sum( $values ), $lines->get_amount()->get_currency() );
-
- $tip = array(
- sprintf(
- /* translators: %s: price excluding tax */
- __( 'Exclusive tax: %s', 'pronamic_ideal' ),
- $total_exclusive
- ),
- );
-
- if ( $lines->get_amount()->has_tax() ) {
- $values = array_map(
- function ( PaymentLine $line ) {
- return $line->get_total_amount()->get_including_tax()->get_value();
- },
- $lines->get_array()
- );
-
- $total_inclusive = new Money( array_sum( $values ), $lines->get_amount()->get_currency() );
-
- $tip[] = sprintf(
- /* translators: %s: price including tax */
- __( 'Inclusive tax: %s', 'pronamic_ideal' ),
- $total_inclusive
- );
- }
-
- printf(
- '%s',
- esc_attr( implode( ' ', $tip ) ), - esc_html( $total_exclusive ) - ); - - ?> + get_amount()->format_i18n() ); ?> |
get_total_amount()->get_tax_value(); + $total_amount = $line->get_total_amount(); + + if ( $total_amount instanceof TaxedMoney ) { + return $total_amount->get_tax_value(); + } + + return null; }, $lines->get_array() ); - $tax_amount = new Money( array_sum( $values ), $lines->get_amount()->get_currency()->get_alphabetic_code() ); + $tax_amount = new Money( \array_sum( $values ), $lines->get_amount()->get_currency() ); - echo esc_html( $tax_amount ); + echo \esc_html( $tax_amount->format_i18n() ); ?> | @@ -175,17 +144,17 @@ function( PaymentLine $line ) {
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
get_id() ); ?> | -get_sku() ); ?> | +get_id() ); ?> | +get_sku() ); ?> | get_image_url(); if ( ! empty( $image_url ) ) { - printf( + \printf( '', - esc_url( $image_url ) + \esc_url( $image_url ) ); } @@ -209,23 +178,23 @@ function( PaymentLine $line ) { $classes[] = 'pronamic-pay-tip'; } - printf( + \printf( '%4$s', - esc_attr( implode( ' ', $classes ) ), - esc_url( $line->get_product_url() ), - esc_attr( $line_title ), - esc_html( $line->get_name() ) + \esc_attr( \implode( ' ', $classes ) ), + \esc_url( $line->get_product_url() ), + \esc_attr( $line_title ), + \esc_html( $line->get_name() ) ); } elseif ( ! empty( $description ) ) { // Description without product URL. - printf( + \printf( '%2$s', - esc_attr( $line->get_description() ), - esc_html( $line->get_name() ) + \esc_attr( $line->get_description() ), + \esc_html( $line->get_name() ) ); } else { // No description and no product URL. - echo esc_html( $line->get_name() ); + echo \esc_html( $line->get_name() ); } ?> @@ -233,40 +202,46 @@ function( PaymentLine $line ) { |
get_unit_price() ) {
+ $unit_price = $line->get_unit_price();
- $tip = array(
- sprintf(
- /* translators: %s: price excluding tax */
- __( 'Exclusive tax: %s', 'pronamic_ideal' ),
- $line->get_unit_price()->get_excluding_tax()
- ),
+ if ( null !== $unit_price ) {
+ $tips = array(
+ \__( 'No tax information.', 'pronamic_ideal' ),
);
- if ( $line->get_unit_price()->has_tax() ) {
- $tip[] = sprintf(
- /* translators: %s: price including tax */
- __( 'Inclusive tax: %s', 'pronamic_ideal' ),
- $line->get_unit_price()->get_including_tax()
+ if ( $unit_price instanceof TaxedMoney ) {
+ $tips = array(
+ \sprintf(
+ /* translators: %s: price excluding tax */
+ \__( 'Exclusive tax: %s', 'pronamic_ideal' ),
+ $unit_price->get_excluding_tax()
+ ),
+ \sprintf(
+ /* translators: %s: price including tax */
+ \__( 'Inclusive tax: %s', 'pronamic_ideal' ),
+ $unit_price->get_including_tax()
+ ),
);
}
- printf(
+ \printf(
'%s',
- esc_attr( implode( ' ', $tip ) ), - esc_html( $line->get_unit_price()->get_excluding_tax() ) + \esc_attr( \implode( ' ', $tips ) ), + \esc_html( $unit_price->format_i18n() ) ); } ?> |
- get_quantity() ); ?> | +get_quantity() ); ?> | get_discount_amount() ) { - echo esc_html( $line->get_discount_amount() ); + $discount_amount = $line->get_discount_amount(); + + if ( null !== $discount_amount ) { + echo \esc_html( $discount_amount ); } ?> @@ -274,26 +249,31 @@ function( PaymentLine $line ) { |
get_total_amount()->get_excluding_tax()
- ),
+ $line_total = $line->get_total_amount();
+
+ $tips = array(
+ \__( 'No tax information.', 'pronamic_ideal' ),
);
- if ( $line->get_total_amount()->has_tax() ) {
- $tip[] = sprintf(
- /* translators: %s: price including tax */
- __( 'Inclusive tax: %s', 'pronamic_ideal' ),
- $line->get_total_amount()->get_including_tax()
+ if ( $line_total instanceof TaxedMoney ) {
+ $tips = array(
+ \sprintf(
+ /* translators: %s: price excluding tax */
+ \__( 'Exclusive tax: %s', 'pronamic_ideal' ),
+ $line->get_total_amount()->get_excluding_tax()
+ ),
+ \sprintf(
+ /* translators: %s: price including tax */
+ \__( 'Inclusive tax: %s', 'pronamic_ideal' ),
+ $line->get_total_amount()->get_including_tax()
+ ),
);
}
- printf(
+ \printf(
'%s',
- esc_attr( implode( ' ', $tip ) ), - esc_html( $line->get_total_amount()->get_excluding_tax() ) + \esc_attr( \implode( ' ', $tips ) ), + \esc_html( $line_total->format_i18n() ) ); ?> @@ -301,20 +281,17 @@ function( PaymentLine $line ) { |
get_total_amount()->get_tax_amount();
-
- if ( null === $line->get_total_amount()->get_tax_percentage() ) {
-
- echo esc_html( $tax_amount );
-
- } else {
-
- printf(
- '%s',
- esc_attr( number_format_i18n( $line->get_total_amount()->get_tax_percentage() ) . '%' ),
- esc_html( $tax_amount )
- );
+ if ( $line_total instanceof TaxedMoney ) {
+ $tax_amount = $line_total->get_tax_amount();
+ $tax_percentage = $line_total->get_tax_percentage();
+ if ( null !== $tax_amount ) {
+ \printf(
+ '%s',
+ \esc_attr( \number_format_i18n( $tax_percentage ) . '%' ),
+ \esc_html( $tax_amount->format_i18n() )
+ );
+ }
}
?>
diff --git a/views/meta-box-payment-update.php b/views/meta-box-payment-update.php
index 2700b056..4d67b023 100644
--- a/views/meta-box-payment-update.php
+++ b/views/meta-box-payment-update.php
@@ -12,6 +12,10 @@
use Pronamic\WordPress\Pay\Payments\PaymentPostType;
use Pronamic\WordPress\Pay\Plugin;
+if ( ! isset( $post ) ) {
+ return;
+}
+
$states = PaymentPostType::get_payment_states();
$payment = get_pronamic_payment( get_the_ID() );
diff --git a/views/meta-box-subscription-info.php b/views/meta-box-subscription-info.php
index 21a3c776..c246ffe4 100644
--- a/views/meta-box-subscription-info.php
+++ b/views/meta-box-subscription-info.php
@@ -13,6 +13,10 @@
use Pronamic\WordPress\Pay\Subscriptions\SubscriptionStatus;
use Pronamic\WordPress\Pay\Util;
+if ( ! isset( $subscription ) ) {
+ return;
+}
+
$subscription_id = $subscription->get_id();
$customer = $subscription->get_customer();
diff --git a/views/meta-box-subscription-payments.php b/views/meta-box-subscription-payments.php
index 8b486141..9d415dca 100644
--- a/views/meta-box-subscription-payments.php
+++ b/views/meta-box-subscription-payments.php
@@ -11,6 +11,14 @@
use Pronamic\WordPress\Pay\Plugin;
use Pronamic\WordPress\Pay\Subscriptions\SubscriptionStatus;
+if ( ! isset( $periods ) ) {
+ return;
+}
+
+if ( ! isset( $subscription ) ) {
+ return;
+}
+
?>
diff --git a/views/meta-box-subscription-update.php b/views/meta-box-subscription-update.php
index e4b74430..5479922a 100644
--- a/views/meta-box-subscription-update.php
+++ b/views/meta-box-subscription-update.php
@@ -10,6 +10,10 @@
use Pronamic\WordPress\Pay\Subscriptions\SubscriptionPostType;
+if ( ! isset( $post ) ) {
+ return;
+}
+
$states = SubscriptionPostType::get_states();
// WordPress by default doesn't allow `post_author` values of `0`, that's why we use a dash (`-`).
diff --git a/views/notice-license.php b/views/notice-license.php
index 41829cb8..77063cc2 100644
--- a/views/notice-license.php
+++ b/views/notice-license.php
@@ -12,6 +12,10 @@
die;
}
+if ( ! isset( $data ) ) {
+ return;
+}
+
$class = ( 'valid' === $data->license ) ? 'updated' : 'error';
?>
diff --git a/views/notice-upgrade.php b/views/notice-upgrade.php
index fd0ce59f..457e5d1e 100644
--- a/views/notice-upgrade.php
+++ b/views/notice-upgrade.php
@@ -30,7 +30,7 @@
diff --git a/views/page-dashboard.php b/views/page-dashboard.php
index 4a10606e..4cdf4937 100644
--- a/views/page-dashboard.php
+++ b/views/page-dashboard.php
@@ -19,7 +19,7 @@
-
+ |