VbzCart/v1/class/vcPageContent ckout/CapturePage

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search

Call Chains

Code

/*----
      ACTION: receives form input and determines where to save it
	enforces form rules -- mainly, don't allow advance until all required fields are filled in
      OUTPUT:
	* logs Cart event recording which page's form was received
	* sets $this->PageKey_forShow()
	* sets $this->DidRequestAdvance()
      REQUIRES: Input needs to have been parsed so we know what page's data we're capturing
*/
protected function CapturePage() {
	$sPKeyData = $this->GetPageKey_forData();

	// log as system event
	/*
	$arEv = array(
	  fcrEvent::KF_CODE		=> 'CK-PG-REQ',	// checkout page request
	  fcrEvent::KF_DESCR_START	=> 'saving data from page '.$sPKeyData,
	  fcrEvent::KF_WHERE		=> 'ckout.CapturePage',
	  fcrEvent::KF_PARAMS		=> array(
	    'pgData'	=> $sPKeyData,
	    'pgShow'	=> $this->GetPageKey_forShow()
	    )
	  );
	*/
	
	// log cart progress
	$arEv = array(
	    'pgData'	=> $sPKeyData,
	    'pgShow'	=> $this->GetPageKey_forShow()
	    );
	$rcCart = $this->GetCartRecord();
	$rcSysEv = $rcCart->CreateEvent(
	  'CK-PG-REQ',				// CODE: checkout page request
	  'saving data from page '.$sPKeyData,	// TEXT
	  $arEv					// DATA
	  );
	  
	// DEBUGGING
	//echo "PAGE KEY FOR DATA = [$sPKeyData]<br>";
	//$arStat = $this->GetFormObject()->Receive($_POST);

	$out = NULL;	// no processing needed
	switch ($sPKeyData) {
	  case KSQ_PAGE_CART:	// shopping cart
	    $out = $this->CaptureCart();
	    $this->formSeqData = KI_SEQ_CART;	// 0
	    break;
	  case KSQ_PAGE_SHIP:	// shipping information
	    $out = $this->CaptureShipping();
	    $this->formSeqData = KI_SEQ_SHIP;	// 1
	    break;
	  case KSQ_PAGE_PAY:	// billing information
	    $out = $this->CaptureBilling();
	    $this->formSeqData = KI_SEQ_PAY;	// 2
	    break;
	  case KSQ_PAGE_CONF:	// confirmation
	    $out = NULL;	// no processing needed
	    $this->formSeqData = KI_SEQ_CONF;	// 3
	    break;
	  default:
	    $this->formSeqData = NULL;
	    // more likely to be a hacking attempt than an internal error:
	    $out = "Cannot save data from unknown page [$sPKeyData]";
	    $arEv = array(
	      fcrEvent::KF_DESCR_FINISH	=> 'page not recognized',
	      fcrEvent::KF_IS_ERROR	=> TRUE,
	      );
	    $rcSysEv->Finish($arEv);
	}

	$rcCart->UpdateBlob();
	$this->GetFormObject()->Save();

	return $out;
}