• Dan

    (@danscott1121)


    Hi,

    I have paid memberships pro with the register helper add-on.

    I am trying to add extra checkout boxes and some custom fields inside them.

    I have followed the example code and have succeeded in creating the extra aforementioned bits in my checkout/register form.

    The only problem is that it’s putting the custom checkout boxes and fields in a different way to the rest of the checkout boxes and field.

    My custom checkout boxes and fields are coming out as:

    <div id="pmpro_checkout_something" class="pmpro_checkout">
     <h2><span class="pmpro_thead-name">Something Information</span></h2>
     <div class="pmpro_checkout-fields">
      <div id="something_div" class="pmpro_checkout-field">
       <label for="something">Something</label>
       <input type="text" id="something" name="something" value="" size="40" class="company input "  /><span class="pmpro_asterisk"> *</span>
      </div>
     </div> <!-- end pmpro_checkout-fields -->
    </div> <!-- end pmpro_checkout_box-name -->

    Where as I expect it to be as the rest of the checkout boxes are (and it says in the docs that custom checkout boxes will come out like this also):

    <table id="pmpro_something_fields" class="pmpro_checkout" width="100%" cellpadding="0" cellspacing="0" border="0">
     <thead>
      <tr>
       <th>
         <h2 class="sectionHeading">Something Information</h2>
    
    				</th>
    			</tr>
    			</thead>
    			<tbody>
    			<tr>
    				<td>
    					<div>
    						<label for="something">Something</label>
    						<input id="something" name="something" type="text" class="input pmpro_required" size="30" value="" required="required" />
    					</div>
    				</td>
    			</tr>
    			</tbody>
    </table>

    Why is it putting my custom stuff in a different format? Or better yet, how do I make it come out in the above (latter) format? Is there a way to cleanly edit the pmprorh_add_checkout_box() and pmprorh_add_registration_field() functions?

    Here is my code which create the custom checkout box and the field (in a custom plugin):

    <?php
    /*
    Plugin Name: Register Helper Example
    Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/
    Description: Register Helper Initialization Example
    Version: .1
    Author: Stranger Studios
    Author URI: https://www.strangerstudios.com
    */
    //we have to put everything in a function called on init, so we are sure Register Helper is loaded
    function my_pmprorh_init()
    {
    	//don't break if Register Helper is not loaded
    	if(!function_exists("pmprorh_add_registration_field"))
    	{
    		return false;
    	}
    
    	pmprorh_add_checkout_box("something", "2: Something Information");
    
    	$field = new PMProRH_Field("something", "text", array("size"=>40, "class"=>"something", "profile"=>true, "required"=>true));
    	pmprorh_add_registration_field("somthing", $field);
    
    }
    add_action("init", "my_pmprorh_init");

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there I’m having this exact same issue. All the fields and boxes are showing but the formatting is completely different from the fields included by default in pmppro.

    has anyone found a solution as its preventing my website from going live. Help!!

    Thread Starter Dan

    (@danscott1121)

    Hi,

    I did figure it out… Sorry, I should have posted at the time, but here it is now my solution:

    I found the function (in pmpro register helper plugin) which outputs custom checkoutboxes:

    pmprorh_pmpro_checkout_boxes();

    I ‘overrode’ this ^^ function with my own function. My function is a copy-n-paste of pmprorh_pmpro_checkout_boxes(), I just changed the format of the HTML to match the structure of the existing table-based checkout boxes.

    My function is that below, which I added to the pmpro_checkout_boxes hook.

    NOTE: the function below is not in my theme’s functions.php, but in a custom plugin. PMPRO recommends making customization this way (read this).

    You need to remove the old action for the same hook. I ended up doing this in my theme’s functions.php. I tried doing it in the customisations plugin, but it wasn’t working for some reason.

    ‘remove_action(“pmpro_checkout_boxes”, “pmprorh_pmpro_checkout_boxes”);’

    function my_pmprorh_pmpro_checkout_boxes()
    {
    	global $pmprorh_registration_fields, $pmprorh_checkout_boxes;
    
    	foreach($pmprorh_checkout_boxes as $cb)
    	{
    		//how many fields to show at checkout?
    		$n = 0;
    		if(!empty($pmprorh_registration_fields[$cb->name]))
    			foreach($pmprorh_registration_fields[$cb->name] as $field)
    				if(pmprorh_checkFieldForLevel($field) && (!isset($field->profile) || (isset($field->profile) && $field->profile !== "only" && $field->profile !== "only_admin")))		$n++;
    
    		if($n > 0)
    		{
    			?>
    			<table id="pmpro_checkout_box-<?php echo $cb->name; ?>" class="pmpro_checkout">
    				<thead>
    				<tr>
    					<th>
    						<h2 class="sectionHeading"><?php echo $cb->label;?></h2>
    
    						<div class="underline clear"></div>
    						<span class="pmpro_thead-msg"> <a href=""></a></span>
    					</th>
    				</tr>
    				</thead>
    				<tbody>
    				<tr>
    					<td>
    						<?php
    						foreach($pmprorh_registration_fields[$cb->name] as $field)
    						{
    							if(pmprorh_checkFieldForLevel($field) && (!isset($field->profile) || (isset($field->profile) && $field->profile !== "only" && $field->profile !== "only_admin")))
    								$field->displayAtCheckout();
    						}
    						?>
    					</td> <!-- end pmpro_checkout-fields -->
    				</tr>
    				</tbody>
    			</table> <!-- end pmpro_checkout_box-name -->
    			<?php
    		}
    	}
    }
    
    add_action("pmpro_checkout_boxes", "my_pmprorh_pmpro_checkout_boxes");

    Thank you :):) saves having to reinvent the wheel – its unusal they dont follow the same formatting

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Paid Memberships Pro – Adding Custom Checkout Boxes Creating DIVs, Not Tables’ is closed to new replies.