| @@ -454,13 +454,30 @@ | ||
| 454 | 454 | if ($couponroomok !== true) { |
| 455 | 455 | $coupon = []; |
| 456 | 456 | VikError::raiseWarning('', JText::translate('VBCOUPONINVROOM')); |
| 457 | 457 | } |
| 458 | + | |
| 459 | + /** | |
| 460 | + * Trigger event to allow third-party plugins to implement additional coupon validations or manipulation. | |
| 461 | + * | |
| 462 | + * @since 1.16.7 (J) - 1.6.7 (WP) | |
| 463 | + */ | |
| 464 | + if ($couponroomok) { | |
| 465 | + $coupon_validation = VBOFactory::getPlatform()->getDispatcher()->filter('onValidateCouponCode', [&$coupon]); | |
| 466 | + if (is_array($coupon_validation) && in_array(false, $coupon_validation, true)) { | |
| 467 | + // coupon is not valid, errors should be set by the plugin's hook | |
| 468 | + $coupon = []; | |
| 469 | + } | |
| 470 | + } | |
| 471 | + | |
| 458 | 472 | } else { |
| 459 | 473 | $coupon = []; |
| 460 | 474 | VikError::raiseWarning('', JText::translate('VBCOUPONINVDATES')); |
| 461 | 475 | } |
| 462 | 476 | } else { |
| 477 | + if (!$valid_customer_coupon) { | |
| 478 | + $coupon = []; | |
| 479 | + } | |
| 463 | 480 | VikError::raiseWarning('', JText::translate('VBCOUPONNOTFOUND')); |
| 464 | 481 | } |
| 465 | 482 | } |
| 466 | 483 | |
| @@ -513,9 +530,9 @@ | ||
| 513 | 530 | $proomindex = []; |
| 514 | 531 | } |
| 515 | 532 | $this->roomindex = $proomindex; |
| 516 | 533 | |
| 517 | - // push data to tracker | |
| 534 | + // push initial data to tracker | |
| 518 | 535 | $rooms_ids = []; |
| 519 | 536 | $prices_ids = []; |
| 520 | 537 | foreach ($rooms as $ir => $r) { |
| 521 | 538 | $rooms_ids[$ir] = $r['id']; |
| @@ -520,9 +537,17 @@ | ||
| 520 | 537 | foreach ($rooms as $ir => $r) { |
| 521 | 538 | $rooms_ids[$ir] = $r['id']; |
| 522 | 539 | $prices_ids[$ir] = $prices[$ir]; |
| 523 | 540 | } |
| 524 | - VikBooking::getTracker()->pushDates($pcheckin, $pcheckout, $daysdiff)->pushParty($arrpeople)->pushRooms($rooms_ids, $prices_ids, $proomindex)->closeTrack(); | |
| 541 | + VikBooking::getTracker() | |
| 542 | + ->pushDates($pcheckin, $pcheckout, $daysdiff) | |
| 543 | + ->pushParty($arrpeople) | |
| 544 | + ->pushRooms($rooms_ids, $prices_ids, $proomindex); | |
| 525 | 545 | |
| 546 | + // display the View | |
| 526 | 547 | parent::display($tpl); |
| 548 | + | |
| 549 | + // close tracking | |
| 550 | + VikBooking::getTracker() | |
| 551 | + ->closeTrack(); | |
| 527 | 552 | } |
| 528 | 553 | } |