shortocde inside form editor
-
hi guys,
i wrote a plugin for cf7 that outputs the prices calculated by dropdown values of multi page form page 1 in the 2nd form page. to do so, i used the plugin php shrotcode and a simple [prices] in form part 2. unfortunately since one of the latest updates this doesn’T work no more. i already tried a lot:
– shortcode in functions.php > cf7 data for price calculation not available
– is there a hook i could use to output the prices on form 2 head?
– maybe use js workaround with php to get the prices? but then it’s really hard to get the cf7 form data…how could i achieve this?
code of my plugin:
<? /* Plugin Name: Contact Form 7 Preisberechnung Bavaria-Transfer Plugin URI: https://ff-webdesigner.de/ Description: Berechnet die Kosten für Transferservices innerhalb Contact Form 7 Author: Frank Woelky Version: 0.1b Author URI: https://ff-webdesigner.de/ */ include_once ("/www/htdocs/w0090f11/bavaria-transfer.net/wp-content/themes/enfold/functions.php"); function bavaria_preise_js() { echo '<script type="text/javascript" src="/wp-content/plugins/bavaria-preise/bavaria-preise.js"></script>'; } add_action('wp_head', 'bavaria_preise_js'); add_action("wpcf7_before_send_mail", "bavaria_preise"); function bavaria_preise($cf7) { $wpcf = WPCF7_ContactForm::get_current(); if(stripos($wpcf->form,"bavaria_preise()")===FALSE)return FALSE; // wenn nicht erster schritt formular // ansonsten: $p_data =cf7msm_get('cf7msm_posted_data'); $csv=daten_einlesen(); //echo "<pre>"; //print_r( $p_data); //echo "</pre>"; //print_r($csv); // plz preis ermitteln for($z=2;$z<count($csv);$z++) { if($csv[$z+2][0]==$p_data['abholort']) { $plz_preis=$csv[$z+2][1]; break; } } // transfertyp grundpreis switch ($p_data['transfertyp']) { case "Sammeltransfer": $transfertyp=1; break; case "Express-Fahrt": $transfertyp=9; break; case "Einzelfahrt": $transfertyp=17; break; case "VIP-Service": $transfertyp=25; break; } if($p_data['transfertyp']=="Sammeltransfer"||$p_data['transfertyp']=="Express-Fahrt") $personen=$p_data['personen']-$p_data['unter14']; else $personen=$p_data['personen']; $preis_transfertyp=$csv[1][$transfertyp+$personen]; // aufpreise für kinder if($p_data['transfertyp']=="Sammeltransfer"||$p_data['transfertyp']=="Express-Fahrt") $aufpreis_kinder=$p_data['unter14']*7; if($p_data['step']=='1-3')$pro_strecke=" pro Strecke"; $preis=$plz_preis + $preis_transfertyp + $aufpreis_kinder; if($p_data['transfer']=='Hin- und Rückfahrt'&& $p_data['step']=='2-3')$preis*=2; $preis='<div id="ff_preis">Preis: <span id="ff_preis_inner">'.$preis.',00 € '.$pro_strecke.'</span></div>'; return $preis; } function hidden_price_field() { $preis=strip_tags(bavaria_preise()); $output='<input class="wpcf7-form-control wpcf7-text hidden" type="text" value="'.$preis.'" name="preis">'; return $output; } function daten_einlesen(){ $datei=$_SERVER['DOCUMENT_ROOT'].'wp-content/plugins/bavaria-preise/preise.csv'; $zeilen = file($datei); foreach($zeilen as &$zeile) { $csv[] = explode(";",$zeile); //parse the items in rows } return $csv; } function PLZ_dropdown($choices, $args=array()) { $csv=daten_einlesen(); $choices = array(); for($z=2;$z<count($csv);$z++) { $choices[$csv[$z+2][0]]=$csv[$z+2][0]; } return $choices; } add_filter('PLZ_dropdown', 'PLZ_dropdown', 10, 2); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘shortocde inside form editor’ is closed to new replies.