Files
shopPRO/autoload/admin/factory/class.ShopCoupon.php
2024-10-23 13:44:50 +02:00

55 lines
1.6 KiB
PHP

<?php
namespace admin\factory;
class ShopCoupon
{
static public function details( int $coupon_id )
{
global $mdb;
return $mdb -> get( 'pp_shop_coupon', '*', [ 'id' => $coupon_id ] );
}
public static function coupon_delete( $coupon_id )
{
global $mdb;
return $mdb -> delete( 'pp_shop_coupon', [ 'id' => $coupon_id ] );
}
public static function save( $coupon_id, $name, $status, $send, $used, $type, $amount, $one_time, $include_discounted_product, $categories )
{
global $mdb;
if ( !$coupon_id )
{
if ( $mdb -> insert( 'pp_shop_coupon', [
'name' => $name,
'status' => $status,
'used' => $used,
'type' => $type,
'amount' => $amount,
'one_time' => $one_time,
'send' => $send,
'include_discounted_product' => $include_discounted_product,
'categories' => $categories
] ) )
return $mdb -> id();
}
else
{
$mdb -> update( 'pp_shop_coupon', [
'name' => $name,
'status' => $status,
'used' => $used,
'type' => $type,
'amount' => $amount,
'one_time' => $one_time,
'send' => $send,
'include_discounted_product' => $include_discounted_product,
'categories' => $categories
], [
'id' => $coupon_id
] );
return true;
}
}
}