protected function getCouponsResult($order, $basket)
{
$productQuantity = [];
foreach ($basket as $basketItem) {
$id = $basketItem->getId();
$quantity = $basketItem->getQuantity();
$productQuantity[$id] = $quantity;
}
$orderDiscounts = $order->getDiscount();
$orderDiscounts = $orderDiscounts->getApplyResult(true);
$couponsList = $orderDiscounts['COUPON_LIST'];
$couponsBasket = $orderDiscounts['RESULT']['BASKET'];
$couponsPrices = $orderDiscounts['PRICES']['BASKET'];
$coupons = [];
foreach ($couponsList as $code => $data) {
$coupons[$data['ORDER_DISCOUNT_ID']] = $code;
}
$prices = [];
foreach ($couponsPrices as $productID => $data) {
$quantity = isset($productQuantity[$productID]) ? $productQuantity[$productID] : 1;
$prices[$productID] = $data['DISCOUNT'] * $quantity;
}
$result = [];
foreach ($couponsBasket as $productID => $discounts) {
foreach ($discounts as $discount) {
$discountID = $discount['DISCOUNT_ID'];
$code = isset($coupons[$discountID]) ? $coupons[$discountID] : null;
if (!$code) {
continue;
}
$result[$code] = isset($result[$code]) ? $result[$code] : 0;
$price = isset($prices[$productID]) ? $prices[$productID] : 0;
$result[$code] += $price;
}
}
$formattedResult = [];
foreach ($result as $code => $amount) {
$formattedResult = [
'promoCodeId' => $code,
'discountAmount' => $amount * 100
];
}
return $formattedResult;
}
let parent = document.querySelector("ul");
let child = document.querySelectorAll("ul li");
let anchors = document.querySelectorAll('a[href*="#"]');
for (let anchor of anchors) {
anchor.addEventListener("click", function (e) {
e.preventDefault();
for (let i = 0; i < child.length; i++) {
child[i].classList.remove("active");
}
e.target.classList.add("active");
this.parentNode.classList.add("active");
let blockID = anchor.getAttribute("href").substr(1);
document.getElementById(blockID).scrollIntoView({
behavior: "smooth",
block: "start"
});
});
}