• Resolved BrightSpark

    (@brightspark)


    Hi Aurovrata

    I’ve created a page where someone chooses a hotel, adds guests and their preferences, however for some reason I can’t get the email to include the room type (single, double, twin). I’ve tried it as a dropdown, checkbox, and radio button option.
    ______________________

    The mail message returns the following:

    Guests:

    Guest Name Room Type Arrival Date Checkout Date
    Benny 2022-03-16 2022-03-19
    Blu 2022-03-17 2022-03-20`
    ______________________

    Mail message contains this code:
    Guests: [cf7sg-form-badminton-3]
    ______________________

    The functions.php contains:

    add_filter( 'cf7sg_mailtag_cf7sg-form-badminton-3', 'filter_cf7_mailtag_cf7sg_form_badminton_3', 10, 3);
    function filter_cf7_mailtag_cf7sg_form_badminton_3($tag_replace, $submitted, $cf7_key){
      /*the $tag_replace string to change*/
      /*the $submitted an array containing all submitted fields*/
      /*the $cf7_key is a unique string key to identify your form, which you can find in your form table in the dashboard.*/
      if('badminton-3'==$cf7_key ){
        $style = 'style="padding:0 3px;border-collapse:collapse;border-bottom:1px solid black[qtm]';
        $tag_replace ='
        <table>
          <thead><tr><th>Guest Name</th><th>Room Type</th><th>Arrival Date</th><th>Checkout Date</th></tr></thead>
          <tbody>';
        if(!empty($submitted['guest-names'])){
          $style = 'style=[qtm]background-color:#e3e3e3[qtm]';
          $row=1;
          foreach($submitted['guest-names'] as $idx=>$guest){
            $tag_replace .='  <tr><td '.($row%2==0?$style:'').'>'.$guest.'</td><td '.($row%2==0?$style:'').'>'.$array ['room-type'][$idx]. '</td><td '.($row%2==0?$style:'').'>'.$submitted['arrival-date'][$idx]. '</td><td '.($row%2==0?$style:'').'>'.$submitted['checkout-date'][$idx]. '</td></tr>'.PHP_EOL;
            $row++;
          }
        }
        $tag_replace .='
          </tbody>
        </table>
        ';
      }
      return $tag_replace;
    }

    ______________________

    On another topic is there a way to add taking payments for their choice?

    Thanks for any assistance you may be able to point me at.

    Nick ??

    • This topic was modified 3 years, 1 month ago by BrightSpark.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    dropdown, checkbox, and radio button option.

    these are all array data submissions. Are you saying the array is empty each time?

    Have you tried inserting the field mail tag directly into your mail to see if it works?

    add taking payments

    what is a “taking payment”?

    Thread Starter BrightSpark

    (@brightspark)

    Hi Aurovrata
    Thanks for your speedy reply.
    Yes, when I add a couple of guests it shows blank for room type.
    However, if I add the [room-type] code at the bottom of the email the data is shown as:

    row(1):single
    row(2):double

    Thread Starter BrightSpark

    (@brightspark)

    add taking payments

    Means can we link it up to an online payment system so customers may pay online?

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Yes, when I add a couple of guests it shows blank for room type.

    I will check on my server and revert back.

    Means can we link it up to an online payment system so customers may pay online?

    sure, there are multiple payment plugin extensions for cf7. Have you tried any?

    Plugin Author Aurovrata Venet

    (@aurovrata)

    so I finally got time to take a look at this and found the normal dropdown menu/checkbox to work just fine within a table and is reflected in the $submitted data passed to the filter.

    however, you are trying to retrieve your room-type from an array object $array which is likely undefined…

    
    if(!empty($submitted['guest-names'])){
          $style = 'style=[qtm]background-color:#e3e3e3[qtm]';
          $row=1;
          foreach($submitted['guest-names'] as $idx=>$guest){
            $tag_replace .='  <tr><td '.($row%2==0?$style:'').'>'.$guest.'</td><td '.($row%2==0?$style:'').'>'.$array ['room-type'][$idx]. '</td><td '.($row%2==0?$style:'').'>'.$submitted['arrival-date'][$idx]. '</td><td '.($row%2==0?$style:'').'>'.$submitted['checkout-date'][$idx]. '</td></tr>'.PHP_EOL;
            $row++;
          }
        }

    your room-type would be available in the $submitted object,

    
    
    $submitted['room-type']
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding’ is closed to new replies.