Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Примененние купона на скидку.
<?php
define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS", true);
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
if($_REQUEST[cupon]!='') {
if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) {
$number_coupon = $_REQUEST[cupon]; // номер купона
$getCoupon = \Bitrix\Sale\DiscountCouponsManager::getData($number_coupon, true); // получаем информацио о купоне
if ($getCoupon['ACTIVE'] == "Y" && !$_SESSION['CATALOG_USER_COUPONS']) {
$discountName = $getCoupon['DISCOUNT_NAME'];
$takeCoupon = \Bitrix\Sale\DiscountCouponsManager::add($number_coupon); // true - купон есть / false - его нет
if ($takeCoupon) {
$result['success'] = "Купон Активирован";
} else {
$result['error'] = "Ошибка Активации купона";
}
} else if (!$getCoupon['ACTIVE']) {
$result['error'] = "Мы не нашли такого купона :(";
} else {
$result['error'] = "Купон уже активирован, попробуйте другой :(";
}
}
}else {
if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) {
\Bitrix\Sale\DiscountCouponsManager::delete(
"advancecheaper"
);
}
}
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php"); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.