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:
2026-02-17 19:54:21 +01:00
parent a35d26225a
commit 1ba0c12327
29 changed files with 936 additions and 419 deletions

View 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;
}
}