Hi! My question is probably simple but I've been scratching my head for hours now... I'm pretty new to php. I have an online form for orders; when submitted, an email is sent to the shop manager containing the info the client has filled in. So I pass all the info in the code below, but I can't manage to echo the array containing the order's items/qty/item_code. (I'm using Wordpress, Oxygen Builder, Metabox and Code Snippets, if that helps). Here's the code (used as a Code Snippet):
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
if ( 'command-form' !== $config['id'] ) {
return;
}
$name = rwmb_meta( 'name', '', $post_id );
$email = rwmb_meta( 'email', '', $post_id );
$phone = rwmb_meta( 'phone', '', $post_id );
$orders = rwmb_meta( 'order', '', $post_id ); */ ---> this is the array I wish to show the elements from (array --> [0]:{item:"item", qty:"qty", code:"code"]}, [1]:{}, etc...} */
$comments = rwmb_meta( 'comments', '', $post_id );
$reception = rwmb_meta( 'reception', '', $post_id );
$destination = rwmb_meta( 'destination', '', $post_id );
$payment = rwmb_meta( 'payment', '', $post_id );
$body = "Vous avez reçu une nouvelle commande en ligne!
Nom: $name
Courriel: $email
Téléphone: $phone
Commande: */ ---> this is where I want it displayed, but since it is within $body = " ", I can't seem to be able to use foreach( ) or even print_r( )... */
Commentaires: $comments
Réception: $reception
Paiement: $payment";
$headers = ['Content-type: text/html', "Reply-To: $email"];
wp_mail( '
[email protected]', 'Nouvelle commande en ligne', $body );
}, 10, 2 );
Help with this would be greatly appreciated! Please let me know if any details are missing. Thanks in advance!
Jordan