VbzCart/docs/v1/class/vcPageContent ckout/CapturePage: Difference between revisions

From Woozle Writes Code
Jump to navigation Jump to search
imported>Woozle
(Created page with "{{page/code/class/method}} ==Call Chains== * {{l/version/method|vcPageContent_ckout|OnRunCalculations}}() [protected; events system] calls... ** {{l/version/method|vcPageConte...")
 
imported>Woozle
mNo edit summary
Line 4: Line 4:
** {{l/version/method|vcPageContent_ckout|ProcessPage}}() [protected], which calls...
** {{l/version/method|vcPageContent_ckout|ProcessPage}}() [protected], which calls...
*** {{hilite|{{l/version/method|vcPageContent_ckout|CapturePage}}() [protected]}}, which calls...
*** {{hilite|{{l/version/method|vcPageContent_ckout|CapturePage}}() [protected]}}, which calls...
**** {{l/version/method|vcPageContent_ckout|CaptureBilling}}()
**** {{l/version/method|vcPageContent_ckout|CaptureBilling}}(), which is essentially a shortcut to...
***** {{l/version/method|vcCartDataManager|CaptureBillingPage}}()
***** {{l/version/method|vcCartDataManager|CaptureBillingPage}}()
**** {{l/version/method|vcPageContent_ckout|CaptureCart}}() [protected]
**** {{l/version/method|vcPageContent_ckout|CaptureCart}}() [protected]
Line 11: Line 11:
==Code==
==Code==
<source lang=php>
<source lang=php>
    /*----
/*----
       ACTION: receives form input and determines where to save it
       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
enforces form rules -- mainly, don't allow advance until all required fields are filled in
Line 19: Line 19:
* sets $this->DidRequestAdvance()
* sets $this->DidRequestAdvance()
       REQUIRES: Input needs to have been parsed so we know what page's data we're capturing
       REQUIRES: Input needs to have been parsed so we know what page's data we're capturing
    */
*/
    protected function CapturePage() {
protected function CapturePage() {
$sPKeyData = $this->GetPageKey_forData();
$sPKeyData = $this->GetPageKey_forData();


Line 85: Line 85:


return $out;
return $out;
    }
}
</source>
</source>

Revision as of 00:57, 22 April 2019

Template:Page/code/class/method

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;
}