Exemplo n.º 1
0
$siteName = OrderEdit::getSiteName($siteId);
$order = null;
$result = new \Bitrix\Sale\Result();
DiscountCouponsManager::init(DiscountCouponsManager::MODE_MANAGER, array('userId' => isset($_POST["USER_ID"]) ? $_POST["USER_ID"] : 0));
// try to create order from form data & save it
if ($isSavingOperation || $needFieldsRestore) {
    $order = OrderEdit::createOrderFromForm($_POST, $USER->GetID(), true, $_FILES, $result);
    if ($order) {
        if (isset($_POST["SHIPMENT"]) && $_POST["SHIPMENT"]) {
            $dlvRes = Blocks\OrderShipment::updateData($order, $_POST['SHIPMENT']);
            if (!$dlvRes->isSuccess()) {
                $result->addErrors($dlvRes->getErrors());
            }
        }
        if (isset($_POST["PAYMENT"]) && $_POST["PAYMENT"]) {
            $payRes = Blocks\OrderPayment::updateData($order, $_POST['PAYMENT'], !$result->isSuccess());
            if (!$payRes->isSuccess()) {
                $result->addErrors($payRes->getErrors());
            }
        }
        if ($isSavingOperation && $result->isSuccess()) {
            $res = OrderEdit::saveCoupons($order->getUserId(), $_POST);
            if (!$res) {
                $result->addError(new \Bitrix\Main\Entity\EntityError("Can't save coupons!"));
            }
            $res = $order->save();
            if ($res->isSuccess()) {
                if (isset($_POST["BUYER_PROFILE_ID"])) {
                    $profileId = intval($_POST["BUYER_PROFILE_ID"]);
                } else {
                    $profileId = 0;
Exemplo n.º 2
0
 protected function createNewPaymentAction()
 {
     $formData = $this->request['formData'];
     $index = $this->request['index'];
     $order = $this->getOrder($formData);
     if (isset($formData['SHIPMENT']) && is_array($formData['SHIPMENT'])) {
         $res = Admin\Blocks\OrderShipment::updateData($order, $formData['SHIPMENT']);
         $res->getErrorMessages();
     }
     if (isset($formData['PAYMENT']) && is_array($formData['PAYMENT'])) {
         $res = Admin\Blocks\OrderPayment::updateData($order, $formData['PAYMENT']);
         $res->getErrorMessages();
     }
     $payment = $order->getPaymentCollection()->createItem();
     $this->addResultData("PAYMENT", \Bitrix\Sale\Helpers\Admin\Blocks\OrderPayment::getEdit($payment, $index));
 }
Exemplo n.º 3
0
                if ($backUrl) {
                    LocalRedirect($backUrl);
                } else {
                    LocalRedirect('/bitrix/admin/sale_order_payment.php?lang=' . $lang . GetFilterParams('filter_', false));
                }
            } else {
                $errors = $result->getErrorMessages();
            }
        }
    }
}
if ($request->isPost() && check_bitrix_sessid() && $request->get('update')) {
    /**
     * @var $result \Bitrix\Main\Entity\Result;
     */
    $result = \Bitrix\Sale\Helpers\Admin\Blocks\OrderPayment::updateData($saleOrder, $request->get('PAYMENT'));
    $data = $result->getData();
    $payment = array_shift($data['PAYMENT']);
    if ($result->isSuccess()) {
        $saveResult = $saleOrder->save();
        if ($saveResult->isSuccess()) {
            $paymentId = $payment->getId();
            if (strlen($request->getPost("apply")) == 0) {
                if ($backUrl) {
                    LocalRedirect($backUrl);
                } else {
                    LocalRedirect('/bitrix/admin/sale_order_payment.php?lang=' . $lang . GetFilterParams('filter_', false));
                }
            } else {
                LocalRedirect("/bitrix/admin/sale_order_payment_edit.php?lang=" . $lang . "&order_id=" . $orderId . "&payment_id=" . $paymentId . "&backurl=" . urlencode($backUrl) . GetFilterParams("filter_", false));
            }