28 pointsStarting to get into this DEV thingI'm new here
lgedeon
Member
—
8th March 2011
Hi, we are creating a MarketPress plugin that adds additional options to the shipping page and have hit a few road blocks.
Does anyone have working code that we can look at and learn from, that adds a text field or other option to the shipping page and stores it with the order? Any assistance would be appreciated.
Hi, we are creating a MarketPress plugin that adds additional options to the shipping page and have hit a few road blocks.
Does anyone have working code that we can look at and learn from, that adds a text field or other option to the shipping page and stores it with the order? Any assistance would be appreciated.
I haven't tried customizing the shipping page myself so I don't have something to that effect, but I'll check around here for others who may have done so.
You can hook onto the 'mp_checkout_shipping_field' action (see marketpress-includes/template-functions.php line 484) to add a field to the shipping form and you can hook onto the 'mp_shipping_process' action to process the shipping form.
Hope this answers your question.
Please note we will be changing 'mp_checkout_shipping_field' to a filter in an upcoming release.
It's been over a week without any feedback, so I'm marking this one as resolved. If there's further reason to troubleshoot though, feel free to re-open this one.
I am trying to add a custom field to the checkout page. I open and edit the marketpress-includes/template-functions.php file and edit the file by adding some code into the " mp_shipping_form "
When I added my line of code it successfully added a custom field for me which I named IMEI. how ever I am having problems. I will explain the problem, but first here is the code I added:
if ($editable) {
$content .= '<form id="mp_shipping_form" method="post" action="">';
There is more of the code but to save space I stopped here. This form does have a closing tag just not here to save space!
Here Is my problem:
As I stated before if you go to the shopping cart and checkout you will see the custom field add name IMEI on the checkout page. This is successful, but after checkout is complete and you go to the admin area to manage orders under the shipping information I do not see the label IMEI or the information from that custom field. This is the only thing I see:
Full Name: John Berry
Email: jberry@yahoo.com
Address: 163 man Way Dr
City: Queens
State/Province/Region: SC
Postal/Zip Code: 29878
Country: United States
Phone Number: 7049785236
----------------------------------------------------------
It is not showing IMEI
_________________________________
in the same file I added the custom field I see $_SESSION['mp_shipping_info' so I added this code in the area thinking it would save the information
--------------------------------------------------------------------------------
$meta = get_user_meta($current_user->ID, 'mp_shipping_info', true);
//get address
$email = (!empty($_SESSION['mp_shipping_info']['email'])) ? $_SESSION['mp_shipping_info']['email'] : (isset($meta['email']) ? $meta['email']: $current_user->user_email);
$name = (!empty($_SESSION['mp_shipping_info']['name'])) ? $_SESSION['mp_shipping_info']['name'] : (isset($meta['name']) ? $meta['name'] : $current_user->user_firstname . ' ' . $current_user->user_lastname);
$address1 = (!empty($_SESSION['mp_shipping_info']['address1'])) ? $_SESSION['mp_shipping_info']['address1'] : $meta['address1'];
$address2 = (!empty($_SESSION['mp_shipping_info']['address2'])) ? $_SESSION['mp_shipping_info']['address2'] : $meta['address2'];
$city = (!empty($_SESSION['mp_shipping_info']['city'])) ? $_SESSION['mp_shipping_info']['city'] : $meta['city'];
$state = (!empty($_SESSION['mp_shipping_info']['state'])) ? $_SESSION['mp_shipping_info']['state'] : $meta['state'];
$zip = (!empty($_SESSION['mp_shipping_info']['zip'])) ? $_SESSION['mp_shipping_info']['zip'] : $meta['zip'];
$imei = (!empty($_SESSION['mp_shipping_info']['imei'])) ? $_SESSION['mp_shipping_info']['imei'] : $meta['imei'];
$country = (!empty($_SESSION['mp_shipping_info']['country'])) ? $_SESSION['mp_shipping_info']['country'] : $meta['country'];
if (!$country)
$country = $settings['base_country'];
$phone = (!empty($_SESSION['mp_shipping_info']['phone'])) ? $_SESSION['mp_shipping_info']['phone'] : $meta['phone'];
$content = '';
//don't show if logged in
if (!is_user_logged_in() && $editable) {
$content .= '<p class="mp_cart_login_msg">';
$content .= __('Made a purchase here before?', 'mp').' '.__('Login now to retrieve your saved info »', 'mp').'';
$content .= '</p>';
}
---------------------------------------------------------------------
Can you please tell me where I am going wrong? Can you tell me how to make the IMEI show up in the admin area. Please provide coding. If you provide coding I need to know what file to edit and what lines to insert the code on. example on line 450 add <?php code here?>
Currently you're editing the MarketPress template function whereas it's much easier and more efficient to write your own plugin. I've covered a couple of things to that effect in the other thread but ultimately, this falls outside the realm of what we can feasibly provide for in support.
Responses (7)
WPMU DEV Fanatic — 9th March 2011 #
Hello lgedeon,
I haven't tried customizing the shipping page myself so I don't have something to that effect, but I'll check around here for others who may have done so.
Cheers,
David
Developer — 10th March 2011 #
You can hook onto the 'mp_checkout_shipping_field' action (see marketpress-includes/template-functions.php line 484) to add a field to the shipping form and you can hook onto the 'mp_shipping_process' action to process the shipping form.
Hope this answers your question.
Please note we will be changing 'mp_checkout_shipping_field' to a filter in an upcoming release.
Member — 11th March 2011 #
We're doing that, but a few things aren't turning out right. Have you done this? Could you post sample code?
Developer — 14th March 2011 #
What are the issues you are having? If you can be specific we can help you.
Sales & Support Lead — 27th March 2011 #
Hiya folks,
It's been over a week without any feedback, so I'm marking this one as resolved. If there's further reason to troubleshoot though, feel free to re-open this one.
Thanks!
Member — 14th July 2011 #
I am trying to add a custom field to the checkout page. I open and edit the marketpress-includes/template-functions.php file and edit the file by adding some code into the " mp_shipping_form "
When I added my line of code it successfully added a custom field for me which I named IMEI. how ever I am having problems. I will explain the problem, but first here is the code I added:
if ($editable) {
$content .= '<form id="mp_shipping_form" method="post" action="">';
$content .= apply_filters( 'mp_checkout_before_shipping', '' );
$content .= '<table class="mp_cart_shipping">';
$content .= '<thead><tr>';
$content .= '<th colspan="2">'.__('Enter Your Shipping Information:', 'mp').'</th>';
$content .= '</tr></thead>';
$content .= '<tbody>';
$content .= '<tr>';
$content .= '<td align="right">'.__('Email:', 'mp').'*</td><td>';
$content .= apply_filters( 'mp_checkout_error_email', '' );
$content .= '<input size="35" name="email" type="text" value="'.esc_attr($email).'" /></td>';
$content .= '</tr>';
$content .= '<tr>';
$content .= '<td align="right">'. __('Full Name:', 'mp').'*</td><td>';
$content .= apply_filters( 'mp_checkout_error_name', '' );
$content .= '<input size="35" name="name" type="text" value="'.esc_attr($name).'" /> </td>';
$content .= '</tr>';
$content .= '<tr>';
$content .= '<td align="right">'. __('Address:', 'mp').'*</td><td>';
$content .= apply_filters( 'mp_checkout_error_address1', '' );
$content .= '<input size="45" name="address1" type="text" value="'.esc_attr($address1).'" />
';
$content .= '<small>'. __('Street address, P.O. box, company name, c/o', 'mp').'</small>';
$content .= '</td>';
$content .= '</tr>';
$content .= '<tr>';
$content .= '<td align="right">'. __('Address 2:', 'mp').' </td><td>';
$content .= '<input size="45" name="address2" type="text" value="'.esc_attr($address2).'" />
';
$content .= '<small>'.__('Apartment, suite, unit, building, floor, etc.', 'mp').'</small>';
$content .= '</td>';
$content .= '</tr>';
$content .= '<tr>';
$content .= '<td align="right">'.__('City:', 'mp').'*</td><td>';
$content .= apply_filters( 'mp_checkout_error_city', '' );
$content .= '<input size="25" name="city" type="text" value="'.esc_attr($city).'" /></td>';
$content .= '</tr>';
$content .= '<tr>';
$content .= '<td align="right">'.__('State/Province/Region:', 'mp').'*</td><td>';
$content .= apply_filters( 'mp_checkout_error_state', '' );
$content .= '<input size="15" name="state" type="text" value="'.esc_attr($state).'" /></td>';
$content .= '</tr>';
$content .= '<tr>';
$content .= '<td align="right">'.__('Postal/Zip Code:', 'mp').'*</td><td>';
$content .= apply_filters( 'mp_checkout_error_zip', '' );
$content .= '<input size="10" id="mp_zip" name="zip" type="text" value="'.esc_attr($zip).'" /></td>';
$content .= '</tr>';
$content .= '<tr>';
$content .= '<td align="right">'. __('IMEI:', 'mp').'*</td><td>';
$content .= apply_filters( 'mp_checkout_error_imei', '' );
$content .= '<input size="35" name="imei" type="text" value="'.esc_attr($imei).'" /> </td>';
$content .= '</tr>';
$content .= '<tr>';
$content .= '<td align="right">'.__('Country:', 'mp').'*</td><td>';
There is more of the code but to save space I stopped here. This form does have a closing tag just not here to save space!
Here Is my problem:
As I stated before if you go to the shopping cart and checkout you will see the custom field add name IMEI on the checkout page. This is successful, but after checkout is complete and you go to the admin area to manage orders under the shipping information I do not see the label IMEI or the information from that custom field. This is the only thing I see:
Full Name: John Berry
Email: jberry@yahoo.com
Address: 163 man Way Dr
City: Queens
State/Province/Region: SC
Postal/Zip Code: 29878
Country: United States
Phone Number: 7049785236
----------------------------------------------------------
It is not showing IMEI
_________________________________
in the same file I added the custom field I see $_SESSION['mp_shipping_info' so I added this code in the area thinking it would save the information
--------------------------------------------------------------------------------
$meta = get_user_meta($current_user->ID, 'mp_shipping_info', true);
//get address
$email = (!empty($_SESSION['mp_shipping_info']['email'])) ? $_SESSION['mp_shipping_info']['email'] : (isset($meta['email']) ? $meta['email']: $current_user->user_email);
$name = (!empty($_SESSION['mp_shipping_info']['name'])) ? $_SESSION['mp_shipping_info']['name'] : (isset($meta['name']) ? $meta['name'] : $current_user->user_firstname . ' ' . $current_user->user_lastname);
$address1 = (!empty($_SESSION['mp_shipping_info']['address1'])) ? $_SESSION['mp_shipping_info']['address1'] : $meta['address1'];
$address2 = (!empty($_SESSION['mp_shipping_info']['address2'])) ? $_SESSION['mp_shipping_info']['address2'] : $meta['address2'];
$city = (!empty($_SESSION['mp_shipping_info']['city'])) ? $_SESSION['mp_shipping_info']['city'] : $meta['city'];
$state = (!empty($_SESSION['mp_shipping_info']['state'])) ? $_SESSION['mp_shipping_info']['state'] : $meta['state'];
$zip = (!empty($_SESSION['mp_shipping_info']['zip'])) ? $_SESSION['mp_shipping_info']['zip'] : $meta['zip'];
$imei = (!empty($_SESSION['mp_shipping_info']['imei'])) ? $_SESSION['mp_shipping_info']['imei'] : $meta['imei'];
$country = (!empty($_SESSION['mp_shipping_info']['country'])) ? $_SESSION['mp_shipping_info']['country'] : $meta['country'];
if (!$country)
$country = $settings['base_country'];
$phone = (!empty($_SESSION['mp_shipping_info']['phone'])) ? $_SESSION['mp_shipping_info']['phone'] : $meta['phone'];
$content = '';
//don't show if logged in
if (!is_user_logged_in() && $editable) {
$content .= '<p class="mp_cart_login_msg">';
$content .= __('Made a purchase here before?', 'mp').' '.__('Login now to retrieve your saved info »', 'mp').'';
$content .= '</p>';
}
---------------------------------------------------------------------
Can you please tell me where I am going wrong? Can you tell me how to make the IMEI show up in the admin area. Please provide coding. If you provide coding I need to know what file to edit and what lines to insert the code on. example on line 450 add <?php code here?>
WPMU DEV Fanatic — 14th July 2011 #
Hi jseigle85,
I've responded to your prior post on this matter at the following:
http://premium.wpmudev.org/forums/topic/marketpress-add-custom-input-fields-to-checkout-page
Currently you're editing the MarketPress template function whereas it's much easier and more efficient to write your own plugin. I've covered a couple of things to that effect in the other thread but ultimately, this falls outside the realm of what we can feasibly provide for in support.
It's something you'll likely want to find a developer to code.
http://premium.wpmudev.org/wpmu-jobs/
Or as elsewhere mentioned, you could add your vote to threads such as the following:
http://premium.wpmudev.org/forums/topic/marketpress-certain-products-require-custom-data-from-shoppers
Cheers,
David
Become a member