26 lines
535 B
PHP
26 lines
535 B
PHP
<?php
|
|
namespace front\controls;
|
|
class ShopCoupon
|
|
{
|
|
public static function delete_coupon()
|
|
{
|
|
\S::delete_session( 'coupon' );
|
|
header( 'Location: /koszyk' );
|
|
exit;
|
|
}
|
|
|
|
public static function use_coupon()
|
|
{
|
|
$coupon = new \shop\Coupon( 0 );
|
|
$coupon -> load_from_db_by_name( (string)\S::get( 'coupon' ) );
|
|
|
|
if ( $coupon -> is_available() )
|
|
\S::set_session( 'coupon', $coupon );
|
|
else
|
|
\S::alert( 'Podany kod rabatowy jest nieprawidłowy.' );
|
|
|
|
header( 'Location: /koszyk' );
|
|
exit;
|
|
}
|
|
}
|