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:
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user