Answer the question
In order to leave comments, you need to log in
Why isn't a coupon created with an activity interval?
Hello.
I create a coupon like this:
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");
CModule::IncludeModule("iblock");
$COUPON = randString(6);
$addDb = \Bitrix\Sale\Internals\DiscountCouponTable::add(array(
'DISCOUNT_ID' => 3,
'COUPON' => $COUPON,
'TYPE' => \Bitrix\Sale\Internals\DiscountCouponTable::TYPE_ONE_ORDER,
'MAX_USE' => 1,
'USER_ID' => 0,
'DESCRIPTION' => ''
));
01.09.2020 21:47:00
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");
CModule::IncludeModule("iblock");
$COUPON = randString(6);
$unixStart = strtotime(date("d.m.Y H:i:s"));
$unixEnd = $unixStart+43200; //12 часов
$addDb = \Bitrix\Sale\Internals\DiscountCouponTable::add(array(
'DISCOUNT_ID' => 3,
'COUPON' => $COUPON,
'TYPE' => \Bitrix\Sale\Internals\DiscountCouponTable::TYPE_ONE_ORDER,
'MAX_USE' => 1,
"ACTIVE_FROM"=>ConvertTimeStamp($unixStart, "FULL"),
"ACTIVE_TO"=>ConvertTimeStamp($unixEnd, "FULL"),
'USER_ID' => 0,
'DESCRIPTION' => ''
));
Answer the question
In order to leave comments, you need to log in
Try with this type new \Bitrix\Main\Type\DateTime();
AND add error handling:
if (!$addDb->isSuccess())
{
print_r( $addDb->getErrorMessages() );
}
$unixStart = strtotime(date("d.m.Y H:i:s"));
$unixEnd = $unixStart+43200; //12 часов
use date offset like:$objDateTime = new DateTime("01.01.2012 00:00:00"); // "2012-01-01 00:00:00"
$objDateTime->add("1 day"); // "2012-01-02 00:00:00"
$objDateTime->add("-1 day"); // "2011-12-31 00:00:00"
$objDateTime->add("3 months - 5 days + 10 minutes"); // "2012-03-27 00:10:00"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question