public function doSetPostage($data, $form)
    {
        $country = $data["Country"];
        $code = $data["ZipCode"];

        $this->setAvailablePostage($country, $code);
        
        $postage = Session::get("Checkout.AvailablePostage");

        // Check that postage is set, if not, see if we can set a default
        if (array_key_exists("PostageID", $data) && $data["PostageID"]) {
            
            // First is the current postage ID in the list of postage
            // areas
            if ($postage && $postage->exists() && $postage->find("ID", $data["PostageID"])) {
                $id = $data["PostageID"];
            } else {
                $id = $postage->first()->ID;
            }
                
            $data["PostageID"] = $id;
            Session::set("Checkout.PostageID", $id);
        } else {
            // Finally set the default postage
            if ($postage && $postage->exists()) {
                $data["PostageID"] = $postage->first()->ID;
                Session::set("Checkout.PostageID", $postage->first()->ID);
            }
        }

        // Set the form pre-populate data before redirecting
        Session::set("Form.{$form->FormName()}.data", $data);
        
        $url = Controller::join_links($this->Link(), "#{$form->FormName()}");

        return $this->redirect($url);
    }
public function doSetPostage($data, $form)
    {
        $country = $data["Country"];
        $code = $data["ZipCode"];

        $this->setAvailablePostage($country, $code);
        
        $postage = Session::get("Checkout.AvailablePostage");

        // Check that postage is set, if not, see if we can set a default
        if (array_key_exists("PostageID", $data) && $data["PostageID"]) {
            
            // First is the current postage ID in the list of postage
            // areas
            if ($postage && $postage->exists() && $postage->find("ID", $data["PostageID"])) {
                $id = $data["PostageID"];
            } else {
                $id = $postage->first()->ID;
            }
                
            $data["PostageID"] = $id;
            Session::set("Checkout.PostageID", $id);
        } else {
            // Finally set the default postage
            if ($postage && $postage->exists()) {
                $data["PostageID"] = $postage->first()->ID;
                Session::set("Checkout.PostageID", $postage->first()->ID);
            }
        }

        // Set the form pre-populate data before redirecting
        Session::set("Form.{$form->FormName()}.data", $data);
        
        $url = Controller::join_links($this->Link(), "#{$form->FormName()}");

        return $this->redirect($url);
    }
public function doSetPostage ( $ data , $ form ) { $ country = $ data [ "Country" ] ; $ code = $ data [ "ZipCode" ] ; $ this -> setAvailablePostage ( $ country , $ code ) ; $ postage = Session :: get ( "Checkout.AvailablePostage" ) ; // Check that postage is set, if not, see if we can set a default if ( array_key_exists ( "PostageID" , $ data ) && $ data [ "PostageID" ] ) { // First is the current postage ID in the list of postage // areas if ( $ postage && $ postage -> exists ( ) && $ postage -> find ( "ID" , $ data [ "PostageID" ] ) ) { $ id = $ data [ "PostageID" ] ; } else { $ id = $ postage -> first ( ) -> ID ; } $ data [ "PostageID" ] = $ id ; Session :: set ( "Checkout.PostageID" , $ id ) ; } else { // Finally set the default postage if ( $ postage && $ postage -> exists ( ) ) { $ data [ "PostageID" ] = $ postage -> first ( ) -> ID ; Session :: set ( "Checkout.PostageID" , $ postage -> first ( ) -> ID ) ; } } // Set the form pre-populate data before redirecting Session :: set ( "Form.{$form->FormName()}.data" , $ data ) ; $ url = Controller :: join_links ( $ this -> Link ( ) , "#{$form->FormName()}" ) ; return $ this -> redirect ( $ url ) ; }
Method that deals with get postage details and setting the
postage

@param $data
@param $form
Method that deals with get postage details and setting the postage