Naprawione eventy purchase, begin_checkout, view_item, add_to_cart do formatu GA4 (item_id/item_name zamiast id/name, currency PLN, google_business_vertical, poprawne typy danych). Dodany nowy event view_cart na stronie koszyka. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
193 lines
14 KiB
PHP
193 lines
14 KiB
PHP
<? 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'];?>
|
|
</div>
|
|
<?= \Shared\Tpl\Tpl::view( 'shop-order/order-simple', [
|
|
'order' => $this -> order,
|
|
'coupon' => $this -> coupon,
|
|
'statuses' => ( new \Domain\Order\OrderRepository( $GLOBALS['mdb'] ) )->orderStatuses()
|
|
] );?>
|
|
<? if ( $this -> order['status'] == 0 or $this -> order['status'] == 2 ):?>
|
|
<div class="order-bottom">
|
|
<div class="left">
|
|
<div class="content">
|
|
<div class="box-title"><?= ucfirst( \Shared\Helpers\Helpers::lang( 'dane-do-przelewu' ) );?>:</div>
|
|
<?= str_replace( [ '[KWOTA]', '[NR-ZAMOWIENIA]' ], [ \Shared\Helpers\Helpers::decimal( $this -> order['summary'] ) . ' zł', $this -> order['number'] ], $this -> settings['shop_bank_account_info'] );?>
|
|
</div>
|
|
</div>
|
|
<div class="right">
|
|
<div class="content">
|
|
<div class="box-title"><?= $this -> order['payment_method_id'] == 6 ? 'Zapłać za pomocą PAYPO' : ucfirst( \Shared\Helpers\Helpers::lang( 'platnosc-online' ) );?>:</div>
|
|
<? if ( $this -> order['payment_method_id'] == 1 or $this -> order['payment_method_id'] == 3 ):?>
|
|
<div class="payment-info">Co prawda nie wybrałeś żadnej z dostępnych form "szybkich płatności", ale w każdej chwili możesz z nich skorzystać.</div>
|
|
<? endif;?>
|
|
<? if ( ( $this -> order['payment_method_id'] == 2 or $this -> order['payment_method_id'] == 1 or $this -> order['payment_method_id'] == 3 ) and $paymentRepo->isActive( 2 ) ):?>
|
|
<form id="order" action="https://platnosc.hotpay.pl/" method="post">
|
|
<input required name="SEKRET" value="<?= $this -> settings['hotpay_api'];?>" type="hidden">
|
|
<input required name="KWOTA" value="<?= round( $this -> order['summary'], 2 );?>" type="hidden">
|
|
<input required name="NAZWA_USLUGI" value="Zamówienie nr <?= $this -> order['number'];?>" type="hidden">
|
|
<input required name="ADRES_WWW" value="<?= $base . "://" . $_SERVER['SERVER_NAME'];?>/zamowienie/<?= $this -> order['hash'];?>" type="hidden">
|
|
<input required name="ID_ZAMOWIENIA" value="<?= $this -> order['id'];?>" type="hidden">
|
|
<input name="EMAIL" value="<?= $this -> order['client_email'];?>" type="hidden">
|
|
<input name="DANE_OSOBOWE" value="" type="hidden">
|
|
<div class="form-group row agreement">
|
|
<div class="col-12">
|
|
<input type="checkbox" required id="agreement"> <?= \Shared\Helpers\Helpers::lang( 'akceptuje-regulamin-sklepu' );?>
|
|
</div>
|
|
</div>
|
|
<div class="form-group row agreement">
|
|
<div class="col-12">
|
|
<button type="submit" class="btn btn-success"><?= \Shared\Helpers\Helpers::lang( 'zaplac-online' );?> <b><?= \Shared\Helpers\Helpers::decimal( $this -> order['summary'] );?> zł</b></button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<? endif;?>
|
|
<? if ( $this -> order['payment_method_id'] == 6 and $paymentRepo->isActive( 6 ) ):?>
|
|
<?
|
|
global $mdb;
|
|
$przelewy24_hash = md5( time() );
|
|
$mdb -> update( 'pp_shop_orders', [ 'przelewy24_hash' => $przelewy24_hash ], [ 'id' => $this -> order['id'] ] );
|
|
?>
|
|
<form action="<?= $this -> settings['przelewy24_sandbox'] ? 'https://sandbox.przelewy24.pl/trnDirect' : 'https://secure.przelewy24.pl/trnDirect';?>" method="post" class="form" accept-charset="ISO-8859-2">
|
|
<input type="hidden" name="p24_session_id" value="<?= $przelewy24_hash;?>" />
|
|
<input type="hidden" name="p24_merchant_id" value="<?= $this -> settings['przelewy24_merchant_id'];?>" />
|
|
<input type="hidden" name="p24_pos_id" value="<?= $this -> settings['przelewy24_merchant_id'];?>" />
|
|
<input type="hidden" name="p24_amount" value="<?= $this -> order['summary'] * 100;?>" />
|
|
<input type="hidden" name="p24_currency" value="PLN" />
|
|
<input type="hidden" name="p24_description" value="Zamówienie nr <?= $this -> order['number'];?>" />
|
|
<input type="hidden" name="p24_client" value="<?= $this -> order['client_name'] . ' ' . $this -> order['client_surname'];?>" />
|
|
<input type="hidden" name="p24_address" value="<?= $this -> order['client_street'];?>" />
|
|
<input type="hidden" name="p24_zip" value="<?= $this -> order['client_postal_code'];?>" />
|
|
<input type="hidden" name="p24_city" value="<?= $this -> order['client_city'];?>" />
|
|
<input type="hidden" name="p24_country" value="PL" />
|
|
<input type="hidden" name="p24_email" value="<?= $this -> order['client_email'];?>" />
|
|
<input type="hidden" name="p24_language" value="pl" />
|
|
<input type="hidden" name="p24_url_return" value="<?= $base . "://" . $_SERVER['SERVER_NAME'];?>/potwierdzenie-platnosci/<?= $this -> order['hash'];?>" />
|
|
<input type="hidden" name="p24_url_status" value="<?= $base . "://" . $_SERVER['SERVER_NAME'];?>/przelewy24-status" />
|
|
<input type="hidden" name="p24_api_version" value="3.2" />
|
|
<input type="hidden" name="p24_wait_for_result" value="1">
|
|
<input type="hidden" name="p24_method" value="227">
|
|
<input type="hidden" name="p24_sign" value="<?= md5( $przelewy24_hash . '|' . $this -> settings['przelewy24_merchant_id'] . '|' . ( $this -> order['summary'] * 100 ) . '|PLN|' . $this -> settings['przelewy24_crc_key'] );?>" />
|
|
<button type="submit" name="submit_send" class="btn btn-success">Zapłać za pomocą PAYPO <b><?= \Shared\Helpers\Helpers::decimal( $this -> order['summary'] );?> zł</b></button>
|
|
</form>
|
|
<? endif;?>
|
|
<? if ( $this -> order['payment_method_id'] == 6 ):?>
|
|
<div class="box-title">lub skorzystaj z płatności online</div>
|
|
<? endif;?>
|
|
<? if ( ( $this -> order['payment_method_id'] == 6 or $this -> order['payment_method_id'] == 4 or $this -> order['payment_method_id'] == 1 or $this -> order['payment_method_id'] == 3 ) and $paymentRepo->isActive( 4 ) ):?>
|
|
<?
|
|
global $mdb;
|
|
$przelewy24_hash = md5( time() );
|
|
$mdb -> update( 'pp_shop_orders', [ 'przelewy24_hash' => $przelewy24_hash ], [ 'id' => $this -> order['id'] ] );
|
|
?>
|
|
<form action="<?= $this -> settings['przelewy24_sandbox'] ? 'https://sandbox.przelewy24.pl/trnDirect' : 'https://secure.przelewy24.pl/trnDirect';?>" method="post" class="form" accept-charset="ISO-8859-2">
|
|
<input type="hidden" name="p24_session_id" value="<?= $przelewy24_hash;?>" />
|
|
<input type="hidden" name="p24_merchant_id" value="<?= $this -> settings['przelewy24_merchant_id'];?>" />
|
|
<input type="hidden" name="p24_pos_id" value="<?= $this -> settings['przelewy24_merchant_id'];?>" />
|
|
<input type="hidden" name="p24_amount" value="<?= $this -> order['summary'] * 100;?>" />
|
|
<input type="hidden" name="p24_currency" value="PLN" />
|
|
<input type="hidden" name="p24_description" value="Zamówienie nr <?= $this -> order['number'];?>" />
|
|
<input type="hidden" name="p24_client" value="<?= $this -> order['client_name'] . ' ' . $this -> order['client_surname'];?>" />
|
|
<input type="hidden" name="p24_address" value="<?= $this -> order['client_street'];?>" />
|
|
<input type="hidden" name="p24_zip" value="<?= $this -> order['client_postal_code'];?>" />
|
|
<input type="hidden" name="p24_city" value="<?= $this -> order['client_city'];?>" />
|
|
<input type="hidden" name="p24_country" value="PL" />
|
|
<input type="hidden" name="p24_email" value="<?= $this -> order['client_email'];?>" />
|
|
<input type="hidden" name="p24_language" value="pl" />
|
|
<input type="hidden" name="p24_url_return" value="<?= $base . "://" . $_SERVER['SERVER_NAME'];?>/potwierdzenie-platnosci/<?= $this -> order['hash'];?>" />
|
|
<input type="hidden" name="p24_url_status" value="<?= $base . "://" . $_SERVER['SERVER_NAME'];?>/przelewy24-status" />
|
|
<input type="hidden" name="p24_api_version" value="3.2" />
|
|
<input type="hidden" name="p24_wait_for_result" value="1">
|
|
<input type="hidden" name="p24_sign" value="<?= md5( $przelewy24_hash . '|' . $this -> settings['przelewy24_merchant_id'] . '|' . ( $this -> order['summary'] * 100 ) . '|PLN|' . $this -> settings['przelewy24_crc_key'] );?>" />
|
|
<button type="submit" name="submit_send" class="btn btn-success"><?= \Shared\Helpers\Helpers::lang( 'zaplac-online' );?> <b><?= \Shared\Helpers\Helpers::decimal( $this -> order['summary'] );?> zł</b></button>
|
|
</form>
|
|
<? endif;?>
|
|
<?
|
|
if ( ( $this -> order['payment_method_id'] == 6 or $this -> order['payment_method_id'] == 5 or $this -> order['payment_method_id'] == 1 or $this -> order['payment_method_id'] == 3 ) and $paymentRepo->isActive( 5 ) ):
|
|
|
|
$url = 'https://secure.tpay.com';
|
|
|
|
$this -> settings['tpay_sandbox'] ? $id = '1010' : $id = $this -> settings['tpay_id'];
|
|
$this -> settings['tpay_sandbox'] ? $code = 'demo' : $code = $this -> settings['tpay_security_code'];
|
|
$this -> settings['tpay_sandbox'] ? $email = 'biuro@project-pro.pl' : $email = 'sklep@marianek.pl';
|
|
|
|
$url .= '?id=' . $id;
|
|
$url .= '&kwota=' . str_replace( ',', '.', round( $this -> order['summary'], 2 ) );
|
|
$url .= '&opis=' . urlencode( 'Zamówienie nr ' . $this -> order['number'] );
|
|
$url .= '&wyn_email=' . urlencode( $email );
|
|
$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_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>
|
|
<? endif;?>
|
|
</div>
|
|
</div>
|
|
<? endif;?>
|
|
</div>
|
|
</div>
|
|
<? if ( \Shared\Helpers\Helpers::get_session( 'ekomi-purchase' ) and $this -> settings['ekomi_survey'] and ( $this -> order['payment_method_id'] == 1 or $this -> order['payment_method_id'] == 3 ) ):?>
|
|
<? unset( $_SESSION['ekomi-purchase'] );?>
|
|
<?= $this -> settings['ekomi_survey'];?>
|
|
<? endif;?>
|
|
<link class="footer" rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/minimal.css">
|
|
<script class="footer" type="text/javascript" src="/libraries/grid/plugins/icheck/icheck.min.js"></script>
|
|
<script class="footer" type="text/javascript">
|
|
$( function()
|
|
{
|
|
jQuery( '#order-payment input[type="checkbox"]' ).iCheck({
|
|
checkboxClass: 'icheckbox_minimal-blue',
|
|
radioClass: 'iradio_minimal-blue'
|
|
});
|
|
|
|
<? if ( \Shared\Helpers\Helpers::get_session( 'piksel_purchase' ) and $this -> settings[ 'piksel' ] ):?>
|
|
<? unset( $_SESSION['piksel_purchase'] );?>
|
|
fbq(
|
|
'track',
|
|
'Purchase', {
|
|
currency: 'PLN',
|
|
value: <?= str_replace( ',', '.', round( $this -> order['summary'], 2 ) ) - str_replace( ',', '.', round( $this -> order['transport_cost'], 2 ) );?>,
|
|
content_type: 'product',
|
|
contents: [
|
|
<? foreach ( $this -> order['products'] as $product ):?>
|
|
{ id: <?= (int)$product['product_id'];?>, quantity: <?= $product['quantity'];?> }<? if ( $product != end( $this -> order['products'] ) ) echo ',';?>
|
|
<? endforeach;?>
|
|
]
|
|
} );
|
|
<? endif;?>
|
|
|
|
<? if ( \Shared\Helpers\Helpers::get_session('google-analytics-purchase') ):?>
|
|
|
|
<? if ( $this -> settings['google_tag_manager_id'] ):?>
|
|
dataLayer.push({ ecommerce: null });
|
|
dataLayer.push({
|
|
event: "purchase",
|
|
ecommerce: {
|
|
transaction_id: "<?= $this -> order['id'];?>",
|
|
currency: "PLN",
|
|
value: <?= \Shared\Helpers\Helpers::normalize_decimal( round( $this -> order['summary'], 2 ) ) - str_replace( ',', '.', round( $this -> order['transport_cost'], 2 ) );?>,
|
|
shipping: <?= \Shared\Helpers\Helpers::normalize_decimal( $this -> order['transport_cost'] );?>,
|
|
items: [
|
|
<? foreach ( $this -> order['products'] as $product ):?>
|
|
{
|
|
item_id: "<?= $product['product_id'];?>",
|
|
item_name: "<?= str_replace( '"', '', $product['name'] );?>",
|
|
quantity: <?= (int)$product['quantity'];?>,
|
|
price: <?= ((float)$product['price_brutto_promo'] > 0 && (float)$product['price_brutto_promo'] < (float)$product['price_brutto']) ? \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto_promo'] ) : \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto'] );?>,
|
|
google_business_vertical: "retail"
|
|
}<? if ( $product != end( $this -> order['products'] ) ) echo ',';?>
|
|
<? endforeach;?>
|
|
]
|
|
}
|
|
});
|
|
<? endif;?>
|
|
<? unset( $_SESSION['google-analytics-purchase'] );?>
|
|
<? endif;?>
|
|
});
|
|
</script>
|