Jump to content

IftRunner only in backend ?


NorbertH
 Share

Recommended Posts

When saving a page with the "order" template in the backend  IftRunner is nice to me and sends the order via page action into my accounting software. 

When saving "order" in a frontend page it does nothing.   So i certainly missing something . Any ideas? 

 

Link to comment
Share on other sites

Almost 100 % sure fetching all vars from a form, and put them into the page.

Creating an empty page  , so i can add Profields Table (You cannot add this to a not saved page), set some other values like customer and delivery address , set the table with products and then save it again. 

        // Create page
		$b = new Page();
		$b->template="bestellung";
		$bId= $b->save();
		
		// Set basic stats
		$b->bestellung_user_select=$derCustomer;
		$b->bestellung_liefer_addresse_select=$pages->get((int)$input->post->liefer_select);

		if ($input->post->liefer_select=="3826" OR $input->post->liefer_select=="3827")
			$b->bestellung_status_select=$pages->get(3829); // status Barverkauf
		else
			$b->bestellung_status_select=$pages->get(1047); // status bestellt
		
		$b->bemerkung_area=$bemerkung_area;
		
		
		// Add articles (bestellung_artikel_table)
		//$b->of(false); // turn off output formatting
		foreach($myProducts as $prod) { 								
			if (!empty($input->post->artikel[$prod->id]) AND 0< (int)$input->post->artikel[$prod->id]){
				$art= $b->bestellung_artikel_table->makeBlankItem();
				$art->artikel=$prod;
				$art->stueck=$input->post->artikel[$prod->id];
				$b->bestellung_artikel_table->add($art);
				$b->save('bestellung_artikel_table');
			}
		}
		
		// save it all  
		$b->save();
		
		// Show order successfull
		$okBestellt=true;
	
		// Finally delete the post array , so the form is ready to go again  
		$_POST=array();    // Global Post array
		$input->post=null; //  Processwire post 
		$aStueck=array();
		$bemerkung_area="";
	
	} // END of order

Very simple indeed. But it does its job. (Orderpage is just a simple frontend page) 

Edit:

Btw. have no changing field defined so it should not look after changes ?
In the BE it kicks in without any changes.

As a test workaround i simply made a CLI script that simply loads all pages that are not send , and then saves them again. the Hook then kicks in and sends the pages as he should.  

$result=$pages->find('template=46, deny_export=0, bestellung_stueckzahl!="", bestellung_user_select.count!=0, bestellung_liefer_addresse_select.count!=0, bestellung_id_collmex="", limit=2');

foreach ($result AS  $p) {
    echo $p->name."\n";
	$p->save();
}

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...