Index: branches/5.2.x/units/orders/orders_item.php =================================================================== diff -u -N -r14594 -r14641 --- branches/5.2.x/units/orders/orders_item.php (.../orders_item.php) (revision 14594) +++ branches/5.2.x/units/orders/orders_item.php (.../orders_item.php) (revision 14641) @@ -1,6 +1,6 @@ RemoveGiftCertificate($object); - $event->SetRedirectParam('checkout_error', 108); + $this->setCheckoutError(OrderCheckoutErrorType::GIFT_CERTIFICATE, OrderCheckoutError::GC_REMOVED_AUTOMATICALLY); } + $this->SetDBField('GiftCertificateDiscount', $gift_certificate_discount); } @@ -278,4 +279,39 @@ $this->SetDBField('GiftCertificateId', 0); $this->SetDBField('GiftCertificateDiscount', 0); } + + /** + * Sets checkout error + * + * @param int $error_type = {product,coupon,gc} + * @param int $error_code + * @param int $product_id - {ProductId}:{OptionsSalt}:{BackOrderFlag}:{FieldName} + */ + function setCheckoutError($error_type, $error_code, $product_id = null) + { + $errors = $this->Application->RecallVar('checkout_errors'); + $errors = $errors ? unserialize($errors) : Array (); + + if ( isset($product_id) ) { + $error_type .= ':' . $product_id; + + // any error takes priority over FIELD_UPDATE_SUCCESS error + if ( isset($errors[$error_type]) && $error_code == OrderCheckoutError::FIELD_UPDATE_SUCCESS ) { + return ; + } + } + + if ( is_numeric($error_code) ) { + $errors[$error_type] = $error_code; + } + else { + unset($errors[$error_type]); + } + + if ( $this->Application->isDebugMode() ) { + $this->Application->Debugger->appendHTML('CO_ERROR: ' . $error_type . ' - ' . $error_code); + } + + $this->Application->StoreVar('checkout_errors', serialize($errors)); + } } \ No newline at end of file