Documentation

add

boolean public static
\Bitrix\Sale\DiscountCouponsManager::add(
 string $coupon
);

Method adds a coupon to include it in calculations. Static method.

Parameters

ParameterDescriptionVersion
$couponAdded coupon code.

Example

$coupon = "SL-QAGTG-WWLDUA0";  //coupon code, to be included in the order

$order = Sale\Order::load($orderId);
Sale\DiscountCouponsManager::init(
    Sale\DiscountCouponsManager::MODE_ORDER, [
        "userId" => $order->getUserId(),
        "orderId" => $order->getId()
    ]
);
Sale\DiscountCouponsManager::add($coupon);
$discounts = $order->getDiscount();
$discounts->calculate();
$order->save();


© «Bitrix24», 2001-2024
Up