Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-02-21 21:48:03 +01:00
parent 29970ba4ee
commit 846bad0085
21 changed files with 172 additions and 150 deletions

View File

@@ -106,23 +106,26 @@ echo $this -> settings['newsletter_header'];
</td>
<td style="text-align: right; white-space: nowrap; padding: 0 5px;">
<?
echo \Shared\Helpers\Helpers::decimal( $position['price_brutto_promo'] ) . ' zł';
if ( $position['price_brutto_promo'] and $position['price_brutto_promo'] < $position['price_brutto'])
echo '<u style="font-size: 15px; font-weight: 400; color: #c3c3c3; margin-left: 5px; text-decoration: line-through;">' . \Shared\Helpers\Helpers::decimal( $position['price_brutto'] ) . ' zł</u>';
if ( $position['price_brutto_promo'] and $position['price_brutto_promo'] < $position['price_brutto'] )
$discount += \Shared\Helpers\Helpers::normalize_decimal( ( $position['price_brutto'] - $position['price_brutto_promo'] ) * $position['quantity'] );
$_promo = round( (float)$position['price_brutto_promo'], 2 );
$_base = round( (float)$position['price_brutto'], 2 );
if ( $_promo > 0 and $_promo < $_base ) {
echo \Shared\Helpers\Helpers::decimal( $_promo ) . ' zł';
echo '<u style="font-size: 15px; font-weight: 400; color: #c3c3c3; margin-left: 5px; text-decoration: line-through;">' . \Shared\Helpers\Helpers::decimal( $_base ) . ' zł</u>';
$discount += \Shared\Helpers\Helpers::normalize_decimal( ( $_base - $_promo ) * $position['quantity'] );
} else {
echo \Shared\Helpers\Helpers::decimal( $_base ) . ' zł';
}
$_effective = ( $_promo > 0 and $_promo < $_base ) ? $_promo : $_base;
?>
</td>
<td style="text-align: right; white-space: nowrap; padding: 0 5px;">
<?= $position['quantity'];?>
</td>
<td style="text-align: right; white-space: nowrap; padding: 0 5px;">
<?= \Shared\Helpers\Helpers::decimal( \Shared\Helpers\Helpers::normalize_decimal( $position['price_brutto_promo'] * $position['quantity'] ) );?> zł
<?= \Shared\Helpers\Helpers::decimal( \Shared\Helpers\Helpers::normalize_decimal( $_effective * $position['quantity'] ) );?> zł
</td>
</tr>
<? $summary += \Shared\Helpers\Helpers::normalize_decimal( $position['price_brutto'] * $position['quantity'] );?>
<? $summary += \Shared\Helpers\Helpers::normalize_decimal( $_base * $position['quantity'] );?>
<? $quantity += $position['quantity'];?>
<? endforeach; endif;?>
<tr>

View File

@@ -1,4 +1,4 @@
<? global $config; $this -> settings['ssl'] ? $base = 'https' : $base = 'http'; $paymentRepo = new \Domain\PaymentMethod\PaymentMethodRepository( $GLOBALS['mdb'] );?>
<? global $config; $this -> settings['ssl'] ? $base = 'https' : $base = 'http'; $base_secure = 'https'; $paymentRepo = new \Domain\PaymentMethod\PaymentMethodRepository( $GLOBALS['mdb'] );?>
<div class="order-summary">
<div class="box-title">
<?= ucfirst( \Shared\Helpers\Helpers::lang( 'szczegoly-zamowienia' ) );?>: <?= $this -> order['number'];?>
@@ -119,9 +119,9 @@
$url .= '&email=' . urlencode( $this -> order['client_email'] );
$url .= '&nazwisko=' . urlencode( $this -> order['client_name'] . ' ' . $this -> order['client_surname'] );
$url .= '&crc=' . $this -> order['hash'];
$url .= '&result_url=' . urlencode( $base . "://" . $_SERVER['SERVER_NAME'] . '/tpay-status' );
$url .= '&return_url=' . urlencode( $base . "://" . $_SERVER['SERVER_NAME'] . '/potwierdzenie-platnosci/' . $this -> order['hash'] );
$url .= '&return_error_url=' . urlencode( $base . "://" . $_SERVER['SERVER_NAME'] . '/zamowienie/' . $this -> order['hash'] );
$url .= '&result_url=' . urlencode( $base_secure . "://" . $_SERVER['SERVER_NAME'] . '/tpay-status' );
$url .= '&return_url=' . urlencode( $base_secure . "://" . $_SERVER['SERVER_NAME'] . '/potwierdzenie-platnosci/' . $this -> order['hash'] );
$url .= '&return_error_url=' . urlencode( $base_secure . "://" . $_SERVER['SERVER_NAME'] . '/zamowienie/' . $this -> order['hash'] );
$url .= '&md5sum=' . md5( $id . '&' . str_replace( ',', '.', round( $this -> order['summary'], 2 ) ) . '&' . $this -> order['hash'] . '&' . $code );
?>
<button type="button" onclick="document.location.href='<?= $url;?>'" class="btn btn-success"><?= \Shared\Helpers\Helpers::lang( 'zaplac-online' );?> <?= \Shared\Helpers\Helpers::decimal( $this -> order['summary'] );?> zł</b></button>
@@ -189,4 +189,4 @@
<? unset( $_SESSION['google-analytics-purchase'] );?>
<? endif;?>
});
</script>
</script>

View File

@@ -65,20 +65,23 @@
<div class="prices">
<div class="price">
<?
echo \Shared\Helpers\Helpers::decimal( $product['price_brutto_promo'] ) . ' zł';
if ( $product['price_brutto_promo'] and $product['price_brutto_promo'] < $product['price_brutto'] )
echo '<u>' . \Shared\Helpers\Helpers::decimal( $product['price_brutto'] ) . ' zł</u>';
if ( $product['price_brutto_promo'] and $product['price_brutto_promo'] < $product['price_brutto'] )
$discount += \Shared\Helpers\Helpers::normalize_decimal( ( $product['price_brutto'] - $product['price_brutto_promo'] ) * $product['quantity'] );
$_promo = round( (float)$product['price_brutto_promo'], 2 );
$_base = round( (float)$product['price_brutto'], 2 );
if ( $_promo > 0 and $_promo < $_base ) {
echo \Shared\Helpers\Helpers::decimal( $_promo ) . ' zł';
echo '<u>' . \Shared\Helpers\Helpers::decimal( $_base ) . ' zł</u>';
$discount += \Shared\Helpers\Helpers::normalize_decimal( ( $_base - $_promo ) * $product['quantity'] );
} else {
echo \Shared\Helpers\Helpers::decimal( $_base ) . ' zł';
}
$effective_price = ( $_promo > 0 and $_promo < $_base ) ? $_promo : $_base;
?>
<span>x <?= $product['quantity'];?></span>
<?= \Shared\Helpers\Helpers::decimal( \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto'] * $product['quantity'] ) );?> zł
<?= \Shared\Helpers\Helpers::decimal( \Shared\Helpers\Helpers::normalize_decimal( $effective_price * $product['quantity'] ) );?> zł
</div>
</div>
</div>
<? $summary += \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto'] * $product['quantity'] );?>
<? $summary += \Shared\Helpers\Helpers::normalize_decimal( $_base * $product['quantity'] );?>
<? endforeach;?>
<div class="basket-summary">
Wartość koszyka <span><?= \Shared\Helpers\Helpers::decimal( $summary );?> zł</span>