I created a form which will be entered by user
<form id="wc-form-return" action="" method="post">
<label><?php _e('Select products for return','wc_return') ?></label>
<select id="wc_products[]" name="wc_products" class="wc_products" multiple="multiple">
<?php
if ( sizeof( $products ) > 0 ) {
foreach( $products as $item ) { ?>
<option value="<?php echo $item['item_meta']['_product_id'][0]; ?>"><?php echo __(esc_html($item['name']), 'wc_return'); ?></option>
<?php
}
}
?>
</select>
<small><?php _e('You can select multiple by holding down the CMD or Ctrl key.','wc_return'); ?></small>
<textarea name="wc_message" id="wc_message" cols="30" rows="10" placeholder="<?php _e('Explain the reasons for your return', 'wc_return') ?>"></textarea>
<input type="hidden" name="order" value="<?php echo $order->id; ?>" />
<input type="hidden" name="customer" value="<?php echo $order->billing_email; ?>" />
<input type="text" name="phone" id="wc_phone" value="<?php echo $order->billing_phone; ?>" />
<input type="checkbox" name="check1" value="Yes" required>Accept our return and exchange policy </br>
<input type="submit" name="submit" value="<?php _e('Submit','wc_return'); ?>" />
</form>
It will be entered by user and we will be sent to given email (that is already setted up)
Now to give these information in email i used
$note_form_email = '';
if ( $_POST['wc_message'] != '' ) {
$note .= '<br><br>';
$note .= '<p>'.__('And the explanation:', 'wc_return').'</p>';
$note_form_email .= '<p>'.__('And the explanation:', 'wc_return').'</p>';
$note .= apply_filters( 'the_content', $_POST['wc_message'] );
$note_form_email .= apply_filters( 'the_content', $_POST['wc_message'] );
$note .= '<p>'.__('Customer details:', 'wc_return').'</p>';
$note_form_email .= '<p>'.__('Customer details:', 'wc_return').'</p>';
$note .= '<p>'.__('Customer phone:','wc_return').'</p>';
$note_form_email .= '<p>'.__('Customer phone:','wc_return').'</p>';
$note .= apply_filters('the_content', $_POST['wc_phone'] );
$note_form_email .= apply_filters('the_content', $_POST['wc_phone'] );
}
But output was like this
And the explanation:
Huhhh
Customer details:
Customer phone:
That 'Huhhh' was written by user on wc_message. He also wrote wc_phone but it was not showing in email. Wc_message is working properly but wc_phone isnt. What am i doing wrong?
Related
I am trying to build a custom search form in Wordpress where the user would be able to select custom taxonomies to filter the posts against.
I am unfortunately getting this warning:
Warning: urlencode() expects parameter 1 to be string, array given in /wordpress/wp-includes/formatting.php on line 5343, which is this function:
function wp_basename( $path, $suffix = '' ) {
return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) );
}
Here is my code of the form:
<form action="/" method="get">
<?php $post_type = !empty( $_GET['post_type'] ) ? $_GET['post_type'] : 'company'; ?>
<label for="search" class="block"><?php echo __('Search', 'mydomain'); ?>:</label>
<input type="radio" name="post_type" value="company" <?php echo $post_type == 'company' ? 'checked' : ''; ?>>Companies</input>
<input type="radio" name="post_type" value="auditor" <?php echo $post_type == 'auditor' ? 'checked' : ''; ?>>Auditors</input>
<input type="text" name="s" id="search" value="<?php the_search_query(); ?>" class="block" placeholder="<?php echo __('Type here'); ?>" />
<div>
<?php $certificates = get_terms([
'taxonomy' => 'certificate',
'hide_empty' => false
]);
foreach($certificates as $certificate) :
?>
<input type="checkbox" name="certificate[]" id="certificate-<?php echo $certificate->slug; ?>" value="<?php echo $certificate->slug; ?>" <?php echo (!empty($_GET['certificate']) && in_array($certificate->slug, $_GET['certificate']) ) ? 'checked' : ''; ?>> <?php echo $certificate->name; ?>
<?php
endforeach;
?>
</div>
<input type="hidden" value="<?php echo pll_current_language(); ?>" name="lang" id="lang" />
<input type="submit" value="<?php echo __('Search'); ?>" />
</form>
and this is how I attempt to see the search results:
http://wordpress.local/?post_type=auditor&s=&certificate%5B%5D=iso-22000&certificate[]=iso-9001
Any ideas how to bypass this warning and still submit the checkboxes as an array? (custom_tax[])
I have a custom post type called 'bookings' that saves several fields of meta data to wp_postmeta.
I have a page that displays all the entries from this custom post type, i.e. all the bookings.
Here is the code to display my bookings:
<?php
$current_user = wp_get_current_user();
$args = array(
'post_type' => 'bookings',
'meta_query' => array(
array(
'key' => 'wedding_user',
'value' => $current_user->display_name,
'compare' => '=',
)
)
);
// Welcome
echo '<div class="user_avatar">'.get_avatar( $current_user->ID, 32 ).'</div>';
echo '<div class="user_welcome"><p>Hello '.$current_user->display_name.' <span class="user_id">(ID# '.$current_user->ID.')</span></p>';
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
if (get_post_meta( $the_query->post->ID, 'wedding_hidden_is_completed', true )==1) {
$is_complete = 'Form Complete <br /><span class="small">('.get_post_meta( $the_query->post->ID, 'wedding_hidden_date_completed', true ).')</span>';
} else {
$is_complete = 'Not Complete';
}
echo '<p class="booking_id">Booking ID: DISTR' . $the_query->post->ID . '</p>';
echo '<ul class="show_bookings">';
echo '<li>' . get_post_meta( $the_query->post->ID, 'wedding_name', true ) . '</li>';
echo '<li>' . get_post_meta( $the_query->post->ID, 'wedding_date', true ) . '</li>';
echo '<li>' . get_post_meta( $the_query->post->ID, 'wedding_package', true ) . '</li>';
echo '<li>£' . get_post_meta( $the_query->post->ID, 'wedding_price', true ). '</li>';
echo '<li>' . get_post_meta( $the_query->post->ID, 'wedding_payment_due_date', true ) . '</li>';
echo '<li>' . $is_complete . '</li>';
echo '<li>Is Viewed?</li>';
echo '<li>Actions';
echo '<ul class="actions-sub-menu">';
echo '<li>Fill out booking form</li>';
echo '<li>Pay deposit</li>';
echo '<li>Pay remaining balance</li>';
echo '<li>Email a copy of your receipt</li>';
echo '<li>View booking form</li>';
echo '</ul>';
echo '</li> <!--end actions-sub-menu-->';
echo '</ul>';
?>
<div class="pay_deposit">
<?php
require DISTRACTIONS_LOGIN_PLUGIN_DIR . 'includes/payments/deposit.php';
?>
</div> <!-- end pay deposit -->
<?php
}
} else {
echo '<p>No bookings found</p>';
}
/* Restore original Post Data */
wp_reset_postdata();
?>
under each booking is a paypal payment button - it uses paypal IPN, so nothing too complex (you will see the required file in the "pay_deposit" div).
Here is my paypal payment form:
<?php
$paypal_url='https://www.sandbox.paypal.com/cgi-bin'; //
$paypal_id='malik#thedistractionsband.co.uk'; // Business email ID
$booking_form_id = $the_query->post->ID;
$total_amount = get_post_meta( $the_query->post->ID, 'wedding_price', true );
$deposit_amount = $total_amount*0.2;
?>
<h3>Pay Deposit</h3>
<p>Your deposit aount of £<?php echo $deposit_amount; ?> ...</p>
<form action="<?php echo $paypal_url; ?>" method="post" name="frmPayPal1">
<input type="hidden" name="business" value="<?php echo $paypal_id; ?>">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="<?php echo get_post_meta( $the_query->post->ID, 'wedding_name', true ); ?> - 20% Deposit">
<input type="hidden" name="item_number" value="DISTR<?php echo $booking_form_id; ?>">
<input type="hidden" name="credits" value="510">
<input type="hidden" name="userid" value="<?php echo $current_user->ID; ?>">
<input type="hidden" name="amount" value="<?php echo $deposit_amount; ?>">
<input type="hidden" name="cpp_header_image" value="http://www.thedistractionsband.co.uk/files/2015/08/LOGO-1.1-1024x304.png">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="handling" value="0">
<input type="hidden" name="cancel_return" value="<?php echo get_site_url()."/payment-cancel/"; ?>">
<input type="hidden" name="return" value="<?php echo get_site_url()."/my-bookings/"; ?>">
<input name="notify_url" value="<?php echo DISTRACTIONS_LOGIN_PLUGIN_URL ?>includes/payments/paypal-ipn.php" type="hidden">
<input type="submit" border="0" name="submit" value="Pay Now" alt="PayPal - The safer, easier way to pay online!">
<div class="cards"><i class="fa fa-cc-amex"></i> <i class="fa fa-cc-mastercard"></i> <i class="fa fa-cc-visa"></i> <i class="fa fa-credit-card"></i> <i class="fa fa-cc-paypal"></i></div>
</form>
When a payment is made, it uses the following file to communicated with paypal and update my database - paypal-ipn.php
<?php
// Make wordpress functions available - so we can write to the db etc
$parse_uri = explode( 'wp-content', $_SERVER['SCRIPT_FILENAME'] );
require_once( $parse_uri[0] . 'wp-load.php' );
global $wpdb;
update_post_meta($booking_id, 'deposit_paid', 1);
?>
My issue is in this file. The update_post_meta function is used to add a '1' to the deposit_paid column in my wp_postmeta db table. The issue I have is, how do I define the $booking_id - making sure that it is for the booking that has been paid for.
For example, on my page that lists all my bookings, if the first has post_id 10 and I pay for that, how do I make sure that the 'deposit_paid' entry for post_id 10 is updated?
Figured it out, I need to use:
$booking_id = $_POST['item_number'];
To get the item number sent to paypal (which is the same as the post id)
I am trying to tweak Wordpress Jigoshop according to my customer's needs and I got a bit stuck. What I need is: when a product variation is selected, some additional options appear in the form of radio buttons which customers must chose. I've managed to get everything working, but what I need now is to send the selected radio button to the cart, checkout and so on when the submit button is clicked.
I am trying to use their product customization function to do this and their function is:
if (!function_exists('jigoshop_product_customize_panel')) {
function jigoshop_product_customize_panel() {
global $_product;
if ( isset( $_POST['Submit'] ) && $_POST['Submit'] == 'Save Personalization' ) {
$custom_products = (array) jigoshop_session::instance()->customized_products;
$custom_products[$_POST['customized_id']] = trim( wptexturize( $_POST['jigoshop_customized_product'] ));
jigoshop_session::instance()->customized_products = $custom_products;
}
if ( get_post_meta( $_product->ID , 'customizable', true ) == 'yes' ) :
$custom_products = (array) jigoshop_session::instance()->customized_products;
$custom = isset( $custom_products[$_product->ID] ) ? $custom_products[$_product->ID] : '';
$custom_length = get_post_meta( $_product->ID , 'customized_length', true );
$length_str = $custom_length == '' ? '' : sprintf( __( 'You may enter a maximum of %s characters.', 'jigoshop' ), $custom_length );
echo '<div class="panel" id="tab-customize">';
echo '<p>' . apply_filters('jigoshop_product_customize_heading', __('Enter your personal information as you want it to appear on the product.<br />'.$length_str, 'jigoshop')) . '</p>';
?>
<form action="" method="post">
<input type="hidden" name="customized_id" value="<?php echo esc_attr( $_product->ID ); ?>" />
<?php
if ( $custom_length == '' ) :
?>
<textarea
id="jigoshop_customized_product"
name="jigoshop_customized_product"
cols="60"
rows="4"><?php echo esc_textarea( $custom ); ?>
</textarea>
<?php else : ?>
<input
type="text"
id="jigoshop_customized_product"
name="jigoshop_customized_product"
size="<?php echo $custom_length; ?>"
maxlength="<?php echo $custom_length; ?>"
value="<?php echo esc_attr( $custom ); ?>" />
<?php endif; ?>
<p class="submit"><input name="Submit" type="submit" class="button-alt add_personalization" value="<?php _e( "Save Personalization", 'jigoshop' ); ?>" /></p>
</form>
<?php
echo '</div>';
endif;
}
}
I tried modifying their function to suit my needs and this is what I've come up with (where get_cod is the id and name of the hidden input and "Adauga in cos" is the value of my submit button):
if (!function_exists('salveaza_cod_material')) {
function salveaza_cod_material() {
global $_product;
if ( isset( $_POST['submit']) && $_POST('submit') == 'Adauga in cos') {
$custom_products = (array) jigoshop_session::instance()->customized_products;
$custom_products[$_POST['customized_id']] = trim( wptexturize( $_POST['get_cod'] ));
jigoshop_session::instance()->customized_products = $custom_products;
}
$custom_products = (array) jigoshop_session::instance()->customized_products;
$custom = isset( $custom_products[$_product->ID] ) ? $custom_products[$_product->ID] : '';
}}
However the value isn't sent to the next page. Can anybody please help? Cheers!
Here's an update containing more of the code:
<form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="variations_form cart" method="post">
<fieldset class="variations">
<?php foreach ( $attributes as $name => $options ): ?>
<?php $sanitized_name = sanitize_title( $name ); ?>
<div>
<span class="select_label"><?php echo jigoshop_product::attribute_label('pa_'.$name); ?></span>
<select id="<?php echo esc_attr( $sanitized_name ); ?>" name="tax_<?php echo $sanitized_name; ?>">
<option value=""><?php echo __('Choose an option ', 'jigoshop') ?>…</option>
<?php foreach ( $options as $value ) : ?>
<?php if ( taxonomy_exists( 'pa_'.$sanitized_name )) : ?>
<?php $term = get_term_by( 'slug', $value, 'pa_'.$sanitized_name ); ?>
<option value="<?php echo esc_attr( $term->slug ); ?>"><?php echo $term->name; ?> </option>
<?php else : ?>
<option value="<?php echo esc_attr( sanitize_title( $value ) ); ?>"><?php echo $value; ?></option>
<?php endif;?>
<?php endforeach; ?>
</select>
</div>
<?php endforeach;?>
</fieldset>
<div id="piele-neagra" class="colors" style="display:none">
<ul class="materiale">
<li><input type="radio" name="piele-neagra" value="L73">
<p><img class="alignnone size-full wp-image-155" title="L73" src="http://www.scaune-directoriale.ro/wp-content/uploads/materiale/piele-neagra/L73.gif" alt="L73" width="72" height="72" /></p>
</li>
</ul>
</div>
<div id="stofa-mf" class="colors" style="display:none">
<ul class="materiale">
<li><input type="radio" name="tapiterie" value="MF01" />
...
<div id="stofa-rg" class="colors" style="display:none"> Stofa RG</div>
<div class="clear"></div>
<span id="cod_material"><?php echo esc_attr( $custom ); ?></span>
<span><?php echo trim( wptexturize( $_POST['get_cod'] )); ?></span>
<div class="single_variation"></div>
<?php do_action('jigoshop_before_add_to_cart_form_button'); ?>
<div class="variations_button" style="display:none;">
<input type="hidden" name="variation_id" value="" />
<input type="hidden" name="customized_id" value="<?php echo esc_attr( $_product->ID ); ?>" />
<input type="hidden" id="get_cod" name="get_cod" value="" />
<input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" />
<div class="quantity"><input name="quantity" value="1" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>
<input type="submit" id="submit_cart" class="button-alt" value="<?php esc_html_e('Add to cart', 'jigoshop'); ?>" />
</div>
<?php do_action('salveaza_cod_material'); ?>
<?php do_action('jigoshop_add_to_cart_form'); ?>
</form>
And this is the section of the cart that receives the value:
if ( !empty( $values['variation_id'] )) {
$product_id = $values['variation_id'];
} else {
$product_id = $values['product_id'];
}
$custom_products = (array) jigoshop_session::instance()->customized_products;
$custom = isset( $custom_products[$product_id] ) ? $custom_products[$product_id] : '';
if ( ! empty( $custom_products[$product_id] ) ) :
?>
<dl class="customization">
<dt class="customized_product_label"><?php echo apply_filters('jigoshop_customized_product_label', __('Personal: ','jigoshop') ); ?></dt>
<dd class="customized_product"><?php echo esc_textarea( $custom ); ?></dd>
</dl>
<? php
endif;
?>
It's just a typo: in if ( isset( $_POST['submit']) && $_POST('submit') == 'Adauga in cos'), replace $_POST('submit')by $_POST['submit']
I try to integrate Paybox credit card transaction solution.
I've tries at least 100 differents solutions (not kidding) but no one works and every time i got "Problème d'identification du commerce. Accès refusé !" message (in french).
Here is the most "stable" code I have :
<?php
function gen_hmac($site, $rang, $identifiant, $devise, $cmd, $porteur, $hash, $time, $total, $retour, $key) {
$msg = "PBX_SITE=". $site
."&PBX_RANG=". $rang
."&PBX_IDENTIFIANT=". $identifiant
."&PBC_TOTAL=". $total
."&PBX_DEVISE=". $devise
."&PBC_CMD=". $cmd
."&PBC_PORTEUR=". $porteur
."&PBC_RETOUR=". $retour
."&PBC_HASH=". $hash
."&PBC_TIME=" . $time ;
$binkey = pack("H*", $key);
echo "<!-- " . $msg . " -->";
$hmac = strtoupper(hash_hmac('sha512', $msg, $binkey));
echo "<!-- " . $hmac . " -->";
return $hmac;
}
// static
$site = 1999888;
$rang = 32;
//$identifiant = 110647233;
$identifiant = 107904482;
$devise = 978;
$hash = "SHA512";
$key = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";
$cmd = "TEST Paybox";
$porteur = "test#paybox.com";
$time = date("c");
//$time = "2011-02-28T11:01:50+01:00";
// variable
$total = 1000;
//$retour = "ref:R;trans:T;auto:A;tarif:M;abonnement:B;pays:Y;erreur:E";
$retour = "Mt:M;Ref:R;Auto:A;Erreur:E";
$hmac = gen_hmac($site, $rang, $identifiant, $devise, $cmd, $porteur, $hash, $time, $total, $retour, $key);
?>
<html>
<head>
<title>Paybox TEST</title>
</head>
<body>
<?php
//print_r(hash_algos());
?>
<form method="POST" action="https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi">
<!--<form method="POST" action="https://preprod-tpeweb.paybox.com/cgi/MYframepagepaiement_ip.cgi">-->
<!--<form method="POST" action="https://preprod-tpeweb.paybox.com/cgi/ChoixPaiementMobile.cgi">-->
<input type="hidden" name="PBX_SITE" value="<?php echo $site; ?>" />
<input type="hidden" name="PBX_RANG" value="<?php echo $rang; ?>" />
<input type="hidden" name="PBX_IDENTIFIANT" value="<?php echo $identifiant; ?>" />
<input type="hidden" name="PBX_TOTAL" value="<?php echo $total; ?>" />
<input type="hidden" name="PBX_DEVISE" value="<?php echo $devise; ?>" />
<input type="hidden" name="PBX_CMD" value="<?php echo $cmd; ?>" />
<input type="hidden" name="PBX_PORTEUR" value="<?php echo $porteur; ?>" />
<input type="hidden" name="PBX_RETOUR" value="<?php echo $retour; ?>" />
<input type="hidden" name="PBX_HASH" value="<?php echo $hash; ?>" />
<input type="hidden" name="PBX_TIME" value="<?php echo $time; ?>" />
<input type="hidden" name="PBX_HMAC" value="<?php echo $hmac; ?>" />
<!--<input type="hidden" name="PBX_REFUSE" value="http://test.fr/" />
<input type="hidden" name="PBX_ANNULE" value="http://test.fr/" />
<input type="hidden" name="PBX_EFFECTUE" value="http://test.fr/" />-->
<input type="submit" value="envoyer" />
</form>
</body>
</html>
Most statics values are from paybox test documentation.
So do you know what's wrong with my code or do you know how to have more details about what is wrong on what is send to paybox server ?
Sincerely
EDIT :
More details about my goal. My real need is to code this in java, but I had a few code sample in php which finally helped.
Now I try to find out how to generate a clean hmac/sha512 in java.
<?php
$key = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";
$binkey = pack("H*", $key);
echo strtoupper(hash_hmac('sha512', "ABC", $binkey));
?>
Outputs : 100A6A016A4B21AE120851D51C93B293D95B7D8A44B16ACBEFC2D1C9DF02B6F54FA3C2D6802E52FED5DF8652DDD244788A204682D2D1CE861FDA4E67F2792643
So how can I, in java, recreate the same hmac algorigthm ?
I've try a lot of things but no one achived my goal, but here is what I have currently :
private String generateHMAC( String datas )
{
// final Charset asciiCs = Charset.forName( "utf-8" );
Mac mac;
String result = "";
try
{
byte[] bytesKey = PayboxConstants.KEY.getBytes( );
final SecretKeySpec secretKey = new SecretKeySpec( bytesKey, "HmacSHA512" );
mac = Mac.getInstance( "HmacSHA512" );
mac.init( secretKey );
final byte[] macData = mac.doFinal( datas.getBytes( ) );
byte[] hex = new Hex( ).encode( macData );
result = new String( hex, "ISO-8859-1" );
}
catch ( final NoSuchAlgorithmException e )
{
AppLogService.error( e );
}
catch ( final InvalidKeyException e )
{
AppLogService.error( e );
}
catch ( UnsupportedEncodingException e )
{
AppLogService.error( e );
}
return result.toUpperCase( );
}
But its ouput is : AA6492987D7A7AC81109E877315414806F1973CC47B897ECE713171A25A11B279329B1BFF39EA72A5EFB7EDCD71D1F34D5AAC49999A780BD13F019ED99685B80
Which is definitly not equivalent to "cloned" php hmac algorithm.
So what can I add to my java code to make it compliant with its php equalivalent ?
EDIT :
Actually I managed to makes everything works together, and I available here :
http://dev.lutece.paris.fr/plugins/plugin-paybox/index.html
<section class="rl-box">
<div class="container padd-xs-0">
<div class="content-section1">
<div class="left-cont col-md-12 col-sm-12">
<div class="container-fluid">
<?php
$PBX_SITE = "1999888";
$PBX_RANG = "32";
$PBX_IDENTIFIANT = "your identifiant id";
$secretKeyTest = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";
$PBX_PORTEUR = "your-email";
$PAYBOX_DOMAIN_SERVER = "tpeweb.paybox.com";
$dateTime = date("c");
$PBX_TOTAL = 4000; //$_POST["PBX_TOTAL"]; // Amount
$PBX_DEVISE = 978;
//$PBX_CMD = $_POST["PBX_CMD"]."|".$_POST["user"]."|".$_POST["typed"]."|".$_POST["period"]."|".$_POST["id"]; // order ID no.
$PBX_CMD = 1; // order ID no.Eg: userid,order_id
$PBX_RETOUR = "Mt:M;Ref:R;Auto:A;Erreur:E";
$PBX_HASH = "SHA512";
$PBX_TIME = $dateTime;
//$PBX_EFFECTUE = "http://www.leader-underwriting.eu/payment/payment.php";
$msg = "PBX_SITE=$PBX_SITE" .
"&PBX_RANG=$PBX_RANG" .
"&PBX_IDENTIFIANT=$PBX_IDENTIFIANT" .
"&PBX_TOTAL=$PBX_TOTAL" .
"&PBX_DEVISE=$PBX_DEVISE" .
"&PBX_CMD=$PBX_CMD" .
"&PBX_PORTEUR=$PBX_PORTEUR" .
"&PBX_RETOUR=$PBX_RETOUR" .
"&PBX_HASH=$PBX_HASH" .
"&PBX_TIME=$PBX_TIME";
$binKey = pack("H*", $secretKeyTest);
$hmac = strtoupper(hash_hmac('sha512', $msg, $binKey));
$cuu = str_replace(",", "", $ramount);
?>
<form method="POST" name="form_payment" action="https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi">
<input type="hidden" name="PBX_SITE" value="<?php echo $PBX_SITE; ?>">
<input type="hidden" name="PBX_RANG" value="<?php echo $PBX_RANG; ?>">
<input type="hidden" name="PBX_IDENTIFIANT" value="<?php echo $PBX_IDENTIFIANT; ?>">
<input type="hidden" name="PBX_TOTAL" value="<?php echo $PBX_TOTAL; ?>"> <!--dynamic-->
<input type="hidden" name="PBX_DEVISE" value="<?php echo $PBX_DEVISE; ?>">
<input type="hidden" name="PBX_CMD" value="<?php echo $PBX_CMD; ?>"> <!--dynamic-->
<input type="hidden" name="PBX_PORTEUR" value="<?php echo $PBX_PORTEUR ?>">
<input type="hidden" name="PBX_RETOUR" value="<?php echo $PBX_RETOUR; ?>">
<input type="hidden" name="PBX_HASH" value="<?php echo $PBX_HASH; ?>">
<input type="hidden" name="PBX_TIME" value="<?php echo $PBX_TIME; ?>">
<input type="hidden" name="PBX_HMAC" value="<?php echo $hmac; ?>">
<button type="submit" class="btn btn-primary payment">
Payer
</button>
</form>
<center>
</center>
</div>
</div>
</div> <!-- .container-fluid -->
</div>
</div>
</div>
</section>
I got a custom post type, with a form for storing some data (name, url) to display in a template.
What I want to know is how can I store those values in an array?
An example of my code:
<? function files_metadata(){
global $post;
$custom = get_post_custom($post->ID);
$name = $custom["name"][0];
$url = $custom["url"][0];
echo '<input type="hidden" name="files_metadata" id="files_metadata" value="' .wp_create_nonce('files_m'). '" />'; ?>
<label>Name: </label><br/>
<input id="name" name="name" value="<?php echo $name; ?>" />
<label>Url: </label><br/>
<input id="url" name="url" value="<?php echo $url; ?>" />
<? function save_meta_files($post_id) {
if (!wp_verify_nonce($_POST['files_metadata'], 'files_m')) return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;
update_post_meta($post_id, "name", $_POST["url"]);
update_post_meta($post_id, "url", $_POST["url"]);
}
add_action('save_post', 'save_meta_files'); ?>
To this I want to add something like...
$url = $custom["url"][0];
$url2 = $custom["url"][1];
$url3 = $custom["url"][2];
<input id="url" name="url[0]" value="<?php echo $url; ?>" />
<input id="url2" name="url[1]" value="<?php echo $url2; ?>" />
<input id="url3" name="url[2]" value="<?php echo $url3; ?>" />
update_post_meta($post_id, "url", $_POST["url"][0]);
update_post_meta($post_id, "url2", $_POST["url"][1]);
update_post_meta($post_id, "url3", $_POST["url"][2]);
...but that actually works...
A passed array will be serialized into a string: http://codex.wordpress.org/Function_Reference/update_post_meta
update_post_meta(
$post_id,
'files_metadata',
array(
'name1' => $_POST['name1'],
'url1' => $_POST['url1']
'name2' => $_POST['name2'],
'url2' => $_POST['url2']
)
);