Last active
September 6, 2022 11:43
-
-
Save flayder/b06c3a413d149f87dbdb6a074abbd14d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function applyDiscount(string $coupon) { | |
$is_unused = Sale\DiscountCouponsManager::getEnteredCoupon($coupon); | |
if(!$is_unused) { | |
Sale\DiscountCouponsManager::add($coupon); | |
$oBasket = Sale\Basket::loadItemsForFUser( | |
Sale\Fuser::getId(), | |
Main\Context::getCurrent()->getSite() | |
); | |
$oDiscounts = Sale\Discount::loadByBasket($oBasket); | |
$oBasket->refreshData(['PRICE', 'COUPONS']); | |
$oDiscounts->calculate(); | |
$oDiscounts->getApplyResult(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment