ver. 0.290: ShopCoupon + ShopOrder frontend migration to Domain + Controllers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,13 @@ class ShopBasketController
|
||||
'mainView' => 'Koszyk'
|
||||
];
|
||||
|
||||
private $orderRepository;
|
||||
|
||||
public function __construct( \Domain\Order\OrderRepository $orderRepository )
|
||||
{
|
||||
$this->orderRepository = $orderRepository;
|
||||
}
|
||||
|
||||
public function basketMessageSave()
|
||||
{
|
||||
\Shared\Helpers\Helpers::set_session( 'basket_message', \Shared\Helpers\Helpers::get( 'basket_message' ) );
|
||||
@@ -283,7 +290,7 @@ class ShopBasketController
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $order_id = \front\factory\ShopOrder::basket_save(
|
||||
if ( $order_id = $this->orderRepository->createFromBasket(
|
||||
$client[ 'id' ],
|
||||
\Shared\Helpers\Helpers::get_session( 'basket' ),
|
||||
\Shared\Helpers\Helpers::get_session( 'basket-transport-method-id' ),
|
||||
@@ -326,7 +333,7 @@ class ShopBasketController
|
||||
if ( $redis )
|
||||
$redis -> flushAll();
|
||||
|
||||
header( 'Location: /zamowienie/' . \front\factory\ShopOrder::order_hash( $order_id ) );
|
||||
header( 'Location: /zamowienie/' . $this->orderRepository->findHashById( $order_id ) );
|
||||
exit;
|
||||
}
|
||||
else
|
||||
|
||||
34
autoload/front/Controllers/ShopCouponController.php
Normal file
34
autoload/front/Controllers/ShopCouponController.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace front\Controllers;
|
||||
|
||||
use Domain\Coupon\CouponRepository;
|
||||
|
||||
class ShopCouponController
|
||||
{
|
||||
private CouponRepository $repository;
|
||||
|
||||
public function __construct( CouponRepository $repository )
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function useCoupon()
|
||||
{
|
||||
$coupon = $this->repository->findByName( (string)\Shared\Helpers\Helpers::get( 'coupon' ) );
|
||||
|
||||
if ( $coupon && $this->repository->isAvailable( $coupon ) )
|
||||
\Shared\Helpers\Helpers::set_session( 'coupon', $coupon );
|
||||
else
|
||||
\Shared\Helpers\Helpers::alert( 'Podany kod rabatowy jest nieprawidłowy.' );
|
||||
|
||||
header( 'Location: /koszyk' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public function deleteCoupon()
|
||||
{
|
||||
\Shared\Helpers\Helpers::delete_session( 'coupon' );
|
||||
header( 'Location: /koszyk' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,22 @@
|
||||
<?php
|
||||
namespace front\controls;
|
||||
class ShopOrder
|
||||
namespace front\Controllers;
|
||||
|
||||
use Domain\Order\OrderRepository;
|
||||
|
||||
class ShopOrderController
|
||||
{
|
||||
public static function payment_confirmation()
|
||||
private $repository;
|
||||
|
||||
public function __construct( OrderRepository $repository )
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function paymentConfirmation()
|
||||
{
|
||||
global $settings;
|
||||
|
||||
$order = \front\factory\ShopOrder::order_details( null, \Shared\Helpers\Helpers::get( 'order_hash' ) );
|
||||
$order = $this->repository->orderDetailsFrontend( null, \Shared\Helpers\Helpers::get( 'order_hash' ) );
|
||||
|
||||
return \Shared\Tpl\Tpl::view( 'shop-order/payment-confirmation', [
|
||||
'order' => $order,
|
||||
@@ -14,20 +24,18 @@ class ShopOrder
|
||||
] );
|
||||
}
|
||||
|
||||
public static function payment_status_tpay()
|
||||
public function paymentStatusTpay()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
file_put_contents( 'tpay.txt', print_r( $_POST, true ) . print_r( $_GET, true ), FILE_APPEND );
|
||||
|
||||
if ( \Shared\Helpers\Helpers::get( 'tr_status' ) == 'TRUE' and \Shared\Helpers\Helpers::get( 'tr_crc' ) )
|
||||
if ( \Shared\Helpers\Helpers::get( 'tr_status' ) == 'TRUE' && \Shared\Helpers\Helpers::get( 'tr_crc' ) )
|
||||
{
|
||||
$order = new \shop\Order( 0, \Shared\Helpers\Helpers::get( 'tr_crc' ) );
|
||||
|
||||
if ( $order -> id )
|
||||
if ( $order->id )
|
||||
{
|
||||
$order -> set_as_paid( true );
|
||||
$order -> update_status( 4, true );
|
||||
$order->set_as_paid( true );
|
||||
$order->update_status( 4, true );
|
||||
echo 'TRUE';
|
||||
exit;
|
||||
}
|
||||
@@ -37,9 +45,9 @@ class ShopOrder
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function payment_status_przelewy24pl()
|
||||
public function paymentStatusPrzelewy24pl()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
global $settings;
|
||||
|
||||
$post = [
|
||||
'p24_merchant_id' => \Shared\Helpers\Helpers::get( 'p24_merchant_id' ),
|
||||
@@ -62,24 +70,21 @@ class ShopOrder
|
||||
|
||||
$order = new \shop\Order( 0, '', \Shared\Helpers\Helpers::get( 'p24_session_id' ) );
|
||||
|
||||
if ( $order['status'] == 0 and $order['summary'] * 100 == \Shared\Helpers\Helpers::get( 'p24_amount' ) )
|
||||
if ( $order['status'] == 0 && $order['summary'] * 100 == \Shared\Helpers\Helpers::get( 'p24_amount' ) )
|
||||
{
|
||||
if ( $order['id'] )
|
||||
{
|
||||
$mdb -> update( 'pp_shop_orders', [ 'status' => 1, 'paid' => 1 ], [ 'id' => $order['id'] ] );
|
||||
$mdb -> insert( 'pp_shop_order_statuses', [ 'order_id' => $order['id'], 'status_id' => 1, 'mail' => 1 ] );
|
||||
|
||||
$order -> status = 4;
|
||||
$order -> send_status_change_email();
|
||||
$order->set_as_paid( true );
|
||||
$order->update_status( 4, true );
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function payment_status_hotpay()
|
||||
public function paymentStatusHotpay()
|
||||
{
|
||||
global $mdb, $lang;
|
||||
global $lang;
|
||||
|
||||
if ( !empty( $_POST["KWOTA"] ) && !empty( $_POST["ID_PLATNOSCI"] ) && !empty( $_POST["ID_ZAMOWIENIA"] ) && !empty( $_POST["STATUS"] ) && !empty( $_POST["SEKRET"] ) && !empty( $_POST["HASH"] ) )
|
||||
{
|
||||
@@ -87,7 +92,8 @@ class ShopOrder
|
||||
|
||||
if ( $order['id'] )
|
||||
{
|
||||
if ( is_array( $order['products'] ) and count( $order['products'] ) ):
|
||||
if ( is_array( $order['products'] ) && count( $order['products'] ) ):
|
||||
$summary_tmp = 0;
|
||||
foreach ( $order['products'] as $product ):
|
||||
$product_tmp = \front\factory\ShopProduct::product_details( $product['product_id'], $lang['id'] );
|
||||
$summary_tmp += \Shared\Helpers\Helpers::normalize_decimal( $product['price_netto'] + $product['price_netto'] * $product['vat'] / 100 ) * $product['quantity'];
|
||||
@@ -99,32 +105,21 @@ class ShopOrder
|
||||
{
|
||||
if ( $_POST["STATUS"] == "SUCCESS" )
|
||||
{
|
||||
$mdb -> update( 'pp_shop_orders', [ 'status' => 1, 'paid' => 1 ], [ 'id' => $order['id'] ] );
|
||||
$mdb -> insert( 'pp_shop_order_statuses', [ 'order_id' => $order['id'], 'status_id' => 1, 'mail' => 1 ] );
|
||||
|
||||
$order -> status = 4;
|
||||
$order -> send_status_change_email();
|
||||
$order->set_as_paid( true );
|
||||
$order->update_status( 4, true );
|
||||
|
||||
echo \Shared\Helpers\Helpers::lang( 'zamowienie-zostalo-oplacone' );
|
||||
}
|
||||
else if ( $_POST["STATUS"] == "FAILURE" )
|
||||
{
|
||||
$mdb -> update( 'pp_shop_orders', [ 'status' => 2 ], [ 'id' => $order['id'] ] );
|
||||
$mdb -> insert( 'pp_shop_order_statuses', [ 'order_id' => $order['id'], 'status_id' => 2, 'mail' => 1 ] );
|
||||
|
||||
$order -> status = 2;
|
||||
$order -> send_status_change_email();
|
||||
$order->update_status( 2, true );
|
||||
|
||||
echo \Shared\Helpers\Helpers::lang( 'platnosc-zostala-odrzucona' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdb -> update( 'pp_shop_orders', [ 'status' => 3 ], [ 'id' => $order['id'] ] );
|
||||
$mdb -> insert( 'pp_shop_order_statuses', [ 'order_id' => $order['id'], 'status_id' => 3, 'mail' => 1 ] );
|
||||
|
||||
$order -> status = 3;
|
||||
$order -> send_status_change_email();
|
||||
$order->update_status( 3, true );
|
||||
|
||||
echo \Shared\Helpers\Helpers::lang( 'zamowienie-zostalo-oplacone-reczne' );
|
||||
}
|
||||
@@ -133,13 +128,13 @@ class ShopOrder
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function order_details()
|
||||
public function orderDetails()
|
||||
{
|
||||
global $page, $settings;
|
||||
|
||||
$page['language']['meta_title'] = \Shared\Helpers\Helpers::lang( 'meta-title-szczegoly-zamowienia' ) . ' | ' . $settings['firm_name'];
|
||||
$order = \front\factory\ShopOrder::order_details(
|
||||
\front\factory\ShopOrder::order_id( \Shared\Helpers\Helpers::get( 'order_hash' ) )
|
||||
$order = $this->repository->orderDetailsFrontend(
|
||||
$this->repository->findIdByHash( \Shared\Helpers\Helpers::get( 'order_hash' ) )
|
||||
);
|
||||
$coupon = (int)$order['coupon_id'] ? new \shop\Coupon( (int)$order['coupon_id'] ) : null;
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
namespace front\controls;
|
||||
class ShopCoupon
|
||||
{
|
||||
public static function delete_coupon()
|
||||
{
|
||||
\Shared\Helpers\Helpers::delete_session( 'coupon' );
|
||||
header( 'Location: /koszyk' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function use_coupon()
|
||||
{
|
||||
$coupon = new \shop\Coupon( 0 );
|
||||
$coupon -> load_from_db_by_name( (string)\Shared\Helpers\Helpers::get( 'coupon' ) );
|
||||
|
||||
if ( $coupon -> is_available() )
|
||||
\Shared\Helpers\Helpers::set_session( 'coupon', $coupon );
|
||||
else
|
||||
\Shared\Helpers\Helpers::alert( 'Podany kod rabatowy jest nieprawidłowy.' );
|
||||
|
||||
header( 'Location: /koszyk' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,10 @@ class Site
|
||||
);
|
||||
},
|
||||
'ShopBasket' => function() {
|
||||
return new \front\Controllers\ShopBasketController();
|
||||
global $mdb;
|
||||
return new \front\Controllers\ShopBasketController(
|
||||
new \Domain\Order\OrderRepository( $mdb )
|
||||
);
|
||||
},
|
||||
'ShopClient' => function() {
|
||||
global $mdb;
|
||||
@@ -176,6 +179,18 @@ class Site
|
||||
new \Domain\Client\ClientRepository( $mdb )
|
||||
);
|
||||
},
|
||||
'ShopCoupon' => function() {
|
||||
global $mdb;
|
||||
return new \front\Controllers\ShopCouponController(
|
||||
new \Domain\Coupon\CouponRepository( $mdb )
|
||||
);
|
||||
},
|
||||
'ShopOrder' => function() {
|
||||
global $mdb;
|
||||
return new \front\Controllers\ShopOrderController(
|
||||
new \Domain\Order\OrderRepository( $mdb )
|
||||
);
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class ShopCoupon {
|
||||
private $id;
|
||||
private $name;
|
||||
private $status;
|
||||
private $type;
|
||||
private $amount;
|
||||
private $one_time;
|
||||
private $used;
|
||||
private $include_discounted_product;
|
||||
|
||||
public function __construct() {
|
||||
;
|
||||
}
|
||||
|
||||
public function __get( $var ) {
|
||||
return $this -> $var;
|
||||
}
|
||||
|
||||
public function __set( $var, $value ) {
|
||||
return $this -> $var = $value;
|
||||
}
|
||||
|
||||
public function set_as_used() {
|
||||
global $mdb;
|
||||
$mdb -> update( 'pp_shop_coupon', [ 'used' => 1, 'date_used' => date( 'Y-m-d H:i:s' ) ], [ 'id' => $this -> id ] );
|
||||
$this -> used = 1;
|
||||
}
|
||||
}
|
||||
@@ -1,247 +0,0 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class ShopOrder
|
||||
{
|
||||
public static function order_id( $order_hash )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'pp_shop_orders', 'id', [ 'hash' => $order_hash ] );
|
||||
}
|
||||
|
||||
public static function order_hash( $order_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'pp_shop_orders', 'hash', [ 'id' => $order_id ] );
|
||||
}
|
||||
|
||||
public static function order_details( $order_id = '', $hash = '', $przelewy24_hash = '' )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $order_id )
|
||||
{
|
||||
$order = $mdb -> get( 'pp_shop_orders', '*', [ 'id' => $order_id ] );
|
||||
$order[ 'products' ] = $mdb -> select( 'pp_shop_order_products', '*', [ 'order_id' => $order_id ] );
|
||||
}
|
||||
|
||||
if ( $hash )
|
||||
{
|
||||
$order = $mdb -> get( 'pp_shop_orders', '*', [ 'hash' => $hash ] );
|
||||
$order[ 'products' ] = $mdb -> select( 'pp_shop_order_products', '*', [ 'order_id' => $order[ 'id' ] ] );
|
||||
}
|
||||
|
||||
if ( $przelewy24_hash )
|
||||
{
|
||||
$order = $mdb -> get( 'pp_shop_orders', '*', [ 'przelewy24_hash' => $przelewy24_hash ] );
|
||||
$order[ 'products' ] = $mdb -> select( 'pp_shop_order_products', '*', [ 'order_id' => $order[ 'id' ] ] );
|
||||
}
|
||||
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
public static function generate_order_number()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$date = date( 'Y-m' );
|
||||
|
||||
$results = $mdb -> query( 'SELECT MAX( CONVERT( substring_index( substring_index( number, \'/\', -1 ), \' \', -1 ), UNSIGNED INTEGER) ) FROM pp_shop_orders WHERE date_order LIKE \'' . $date . '%\'' ) -> fetchAll();
|
||||
if ( is_array( $results ) and count( $results ) )
|
||||
foreach ( $results as $row )
|
||||
$nr = ++$row[ 0 ];
|
||||
|
||||
if ( !$nr )
|
||||
$nr = 1;
|
||||
|
||||
if ( $nr < 10 )
|
||||
$nr = '00' . $nr;
|
||||
|
||||
if ( $nr < 100 and $nr >= 10 )
|
||||
$nr = '0' . $nr;
|
||||
|
||||
return date( 'Y/m', strtotime( $date ) ) . '/' . $nr;
|
||||
}
|
||||
|
||||
public static function basket_save(
|
||||
$client_id,
|
||||
$basket,
|
||||
$transport_id,
|
||||
$payment_id,
|
||||
$email,
|
||||
$phone,
|
||||
$name,
|
||||
$surname,
|
||||
$street,
|
||||
$postal_code,
|
||||
$city,
|
||||
$firm_name,
|
||||
$firm_street,
|
||||
$firm_postal_code,
|
||||
$firm_city,
|
||||
$firm_nip,
|
||||
$inpost_info,
|
||||
$orlen_point_id,
|
||||
$orlen_point_info,
|
||||
$coupon,
|
||||
$basket_message )
|
||||
{
|
||||
global $mdb, $lang_id, $settings;
|
||||
|
||||
if ( $client_id )
|
||||
$email = ( new \Domain\Client\ClientRepository( $mdb ) )->clientEmail( (int)$client_id );
|
||||
|
||||
if ( !is_array( $basket ) or !$transport_id or !$payment_id or !$email or !$phone or !$name or !$surname )
|
||||
return false;
|
||||
|
||||
$transport = \front\factory\ShopTransport::transport( $transport_id );
|
||||
$payment_method = \front\factory\ShopPaymentMethod::payment_method( $payment_id );
|
||||
$basket_summary = \Domain\Basket\BasketCalculator::summaryPrice( $basket, $coupon );
|
||||
$order_number = self::generate_order_number();
|
||||
$order_date = date( 'Y-m-d H:i:s' );
|
||||
$hash = md5( $order_number . time() );
|
||||
|
||||
if ( $transport['delivery_free'] == 1 and $basket_summary >= $settings['free_delivery'] )
|
||||
$transport_cost = '0.00';
|
||||
else
|
||||
$transport_cost = $transport['cost'];
|
||||
|
||||
$mdb -> insert( 'pp_shop_orders', [
|
||||
'number' => $order_number,
|
||||
'client_id' => $client_id ? $client_id : null,
|
||||
'date_order' => $order_date,
|
||||
'comment' => null,
|
||||
'client_name' => $name,
|
||||
'client_surname' => $surname,
|
||||
'client_email' => $email,
|
||||
'client_street' => $street,
|
||||
'client_postal_code' => $postal_code,
|
||||
'client_city' => $city,
|
||||
'client_phone' => $phone,
|
||||
'firm_name' => $firm_name ? $firm_name : null,
|
||||
'firm_street' => $firm_street ? $firm_street : null,
|
||||
'firm_postal_code' => $firm_postal_code ? $firm_postal_code : null,
|
||||
'firm_city' => $firm_city ? $firm_city : null,
|
||||
'firm_nip' => $firm_nip ? $firm_nip : null,
|
||||
'transport_id' => $transport_id,
|
||||
'transport' => $transport[ 'name_visible' ],
|
||||
'transport_cost' => $transport_cost,
|
||||
'transport_description' => $transport[ 'description' ],
|
||||
'orlen_point' => ( $orlen_point_id ) ? $orlen_point_id . ' | ' . $orlen_point_info : null,
|
||||
'inpost_paczkomat' => ( $transport_id == 1 or $transport_id == 2 ) ? $inpost_info : null,
|
||||
'payment_method' => $payment_method[ 'name' ],
|
||||
'payment_method_id' => $payment_id,
|
||||
'hash' => $hash,
|
||||
'summary' => \Shared\Helpers\Helpers::normalize_decimal( $basket_summary + $transport_cost ),
|
||||
'coupon_id' => $coupon ? $coupon -> id : null,
|
||||
'message' => $basket_message ? $basket_message : null,
|
||||
'apilo_order_status_date' => date( 'Y-m-d H:i:s' ),
|
||||
] );
|
||||
|
||||
$order_id = $mdb -> id();
|
||||
|
||||
if ( !$order_id )
|
||||
return false;
|
||||
|
||||
if ( $coupon )
|
||||
$mdb -> update( 'pp_shop_coupon', [ 'used_count[+]' => 1 ], [ 'id' => $coupon -> id ] );
|
||||
|
||||
// ustawienie statusu zamówienia
|
||||
$mdb -> insert( 'pp_shop_order_statuses', [ 'order_id' => $order_id, 'status_id' => 0, 'mail' => 1 ] );
|
||||
|
||||
if ( is_array( $basket ) )
|
||||
{
|
||||
foreach ( $basket as $basket_position )
|
||||
{
|
||||
$attributes = '';
|
||||
$product = \shop\Product::getFromCache( $basket_position[ 'product-id' ], $lang_id );
|
||||
|
||||
if ( is_array( $basket_position[ 'attributes' ] ) )
|
||||
{
|
||||
foreach ( $basket_position[ 'attributes' ] as $row )
|
||||
{
|
||||
$row = explode( '-', $row );
|
||||
$attributeRepo = new \Domain\Attribute\AttributeRepository( $mdb );
|
||||
$attribute = $attributeRepo->frontAttributeDetails( (int)$row[ 0 ], $lang_id );
|
||||
$value = $attributeRepo->frontValueDetails( (int)$row[ 1 ], $lang_id );
|
||||
|
||||
if ( $attributes )
|
||||
$attributes .= '<br>';
|
||||
$attributes .= '<b>' . $attribute[ 'language' ][ 'name' ] . '</b>: ';
|
||||
$attributes .= $value[ 'language' ][ 'name' ];
|
||||
}
|
||||
}
|
||||
|
||||
// custom fields
|
||||
$product_custom_fields = '';
|
||||
if ( is_array( $basket_position[ 'custom_fields' ] ) )
|
||||
{
|
||||
foreach ( $basket_position[ 'custom_fields' ] as $key => $val )
|
||||
{
|
||||
$custom_field = \shop\ProductCustomField::getFromCache( $key );
|
||||
if ( $product_custom_fields )
|
||||
$product_custom_fields .= '<br>';
|
||||
$product_custom_fields .= '<b>' . $custom_field[ 'name' ] . '</b>: ' . $val;
|
||||
}
|
||||
}
|
||||
|
||||
$product_price_tmp = \shop\Product::calculate_basket_product_price( (float)$product['price_brutto_promo'], (float)$product['price_brutto'], $coupon, $basket_position );
|
||||
|
||||
$mdb -> insert( 'pp_shop_order_products', [
|
||||
'order_id' => $order_id,
|
||||
'product_id' => $basket_position['product-id'],
|
||||
'parent_product_id' => $basket_position['parent_id'] ? $basket_position['parent_id'] : $basket_position['product-id'],
|
||||
'name' => $product -> language['name'],
|
||||
'attributes' => $attributes,
|
||||
'vat' => $product -> vat,
|
||||
'price_brutto' => $product_price_tmp['price'],
|
||||
'price_brutto_promo' => $product_price_tmp['price_new'],
|
||||
'quantity' => $basket_position['quantity'],
|
||||
'message' => $basket_position['message'],
|
||||
'custom_fields' => $product_custom_fields,
|
||||
] );
|
||||
|
||||
$product_quantity = \shop\Product::get_product_quantity( $basket_position['product-id'] );
|
||||
if ( $product_quantity != null )
|
||||
$mdb -> update( 'pp_shop_products', [ 'quantity[-]' => $basket_position[ 'quantity' ] ], [ 'id' => $basket_position['product-id'] ] );
|
||||
else
|
||||
$mdb -> update( 'pp_shop_products', [ 'quantity[-]' => $basket_position[ 'quantity' ] ], [ 'id' => $basket_position['parent_id'] ] );
|
||||
|
||||
$mdb -> update( 'pp_shop_products', [ 'quantity' => 0 ], [ 'quantity[<]' => 0 ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $coupon and $coupon -> is_one_time() )
|
||||
$coupon -> set_as_used();
|
||||
|
||||
$order = \front\factory\ShopOrder::order_details( $order_id );
|
||||
|
||||
$mail_order = \Shared\Tpl\Tpl::view( 'shop-order/mail-summary', [
|
||||
'settings' => $settings,
|
||||
'order' => $order,
|
||||
'coupon' => $coupon,
|
||||
] );
|
||||
|
||||
$settings[ 'ssl' ] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$mail_order = preg_replace( $regex, "$1" . $base . "://" . $_SERVER[ 'SERVER_NAME' ] . "$2$4", $mail_order );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$mail_order = preg_replace( $regex, "$1" . $base . "://" . $_SERVER[ 'SERVER_NAME' ] . "$2$4", $mail_order );
|
||||
|
||||
\Shared\Helpers\Helpers::send_email( $email, \Shared\Helpers\Helpers::lang( 'potwierdzenie-zamowienia-ze-sklepu' ) . ' ' . $settings[ 'firm_name' ], $mail_order );
|
||||
\Shared\Helpers\Helpers::send_email( $settings[ 'contact_email' ], 'Nowe zamówienie / ' . $settings[ 'firm_name' ] . ' / ' . $order['number'] . ' - ' . $order['client_surname'] . ' ' . $order['client_name'], $mail_order );
|
||||
|
||||
// zmiana statusu w realizacji jeżeli płatność przy odbiorze
|
||||
if ( $payment_id == 3 )
|
||||
{
|
||||
$order_tmp = new \shop\Order( $order_id );
|
||||
$order_tmp -> update_status( 4, true );
|
||||
}
|
||||
|
||||
return $order_id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
namespace front\view;
|
||||
class ShopOrder
|
||||
{
|
||||
public static function order_details( $values )
|
||||
{
|
||||
$tpl = new \Shared\Tpl\Tpl;
|
||||
if ( is_array( $values ) ) foreach ( $values as $key => $val )
|
||||
$tpl -> $key = $val;
|
||||
return $tpl -> render( 'shop-order/order-details' );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user