Using Website Favorites as Order Submission

By Rusty - January 19, 2011 - edited: January 20, 2011

I'm trying to use/manipulate the Website Favorites plug so that a viewer can add individual items from a list page to a list (easily done via Website Favorites). Then from the favorites overview page be able to enter a quantity for each items in the Favorites List. Then the viewer clicks submit, and the email form will pull the User Company Name, Phone, & Address from the User Accounts page, and also include the text from the Text Input (Item quantity) and the Item name.

And I need to display to display the total number of items favorited as well...

Any suggestions on how best to proceed would be greatly appreciated.
Rusty

Re: [Rusty] Using Website Favorites as Order Submission

By Rusty - January 20, 2011 - edited: January 20, 2011

So I've made a bit of headway.

I have a "Favorites Overview" which I'm using as a an Order Review page for a visitor to review items added, and then submit that order via email.

This is my code.

I have a ForEach statement that generates an input field with the item number and appends _qty after it. This lets the user enter in a quantity. I'm having issues calling up that quantity later on upon form submission. PHP syntax is my obstacle I believe.

Anyways I've highlighted the foreach where I create a row in a table. and I've also highlighted where I'm trying to generate and call up the same input fields. *eyebrow wiggle* Fun stuff.

<!--SUBMIT ORDER PART ONE -->
<!--Begin Submission Form -->
<?php

if (!count($_POST)){
?>
<form name="form" id="form" class="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return validate(this)" method="post">
<!--END SUBMIT ORDER PART ONE -->
<table border="1" width="100%" class="order">
<tr><th width="10%">Remove</th><th width="10%">Quantity</th><th width="18%">Form Number</th><th width="62%">Description</th></tr>
<?php foreach ($favoriteRecords as $record): ?>
<?php
$tableOrTag = 'forms'; // Update with your section's table name
$recordNum = $record['num']; // Update this with current record number
?>

<!--Row -->
<tr>
<!--Remove -->
<td><span class="<?php wsf_cssClassFor($tableOrTag, $recordNum, 'remove'); ?>" style="<?php wsf_displayStyleFor($tableOrTag, $recordNum, 'remove'); ?>"><a href="#" onclick="<?php wsf_onClickFor($tableOrTag, $recordNum, 'removeAndReload'); ?>">Remove</a></span></td>
<!--Quantity -->
<td><input type="text" id="<?php echo $record['item_number'] ?>_qty" name="<?php echo $record['item_number'] ?>_qty" maxlength="4" size="4"/></td>
<!--Form Number -->
<td><a href="<?php echo $record['_link'] ?>"><?php echo $record['item_number'] ?></a></td>
<!--Description -->
<td><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></td>
<!--End Row -->
</tr>
<?php endforeach; ?>
<!--SUBMIT ORDER PART TWO -->
<input type="submit" value="Submit Order" tabindex="5" id="submit" class="submit" name="submit"/>
</form>
<?php }else{ ?>
<!-- START SEND MAIL SCRIPT -->
<div id="done">
<p><strong>Order Successfully Submitted!</strong></p>
<p>Thank you for your business!<br/ >
Your order was successfully sent and we will be in touch with you soon.</p>
</div>
<?php error_reporting( E_ALL & ~E_NOTICE );
$mail = $_POST['email'];


$to = "rusty@myemails.com";
$subject = "New Order from Website";
$headers = "From: My Website <noreply@mywebsite.com>";
$message = "Sent from the Order Website\n";
foreach ($favoriteRecords as $record) {

Where I'm Having Issues
It successfully sends the email, but with out the quantity, and doesn't even manage to include the title or item number.
It's hanging up on the Join...providing me with this:
Warning: join(): Invalid arguments passed

$qty_string = join ("_qty",$record['item_number']);
$message = "\Quantity:" . $_POST['qty_string'];
$message .= "\Item Number:" . $_POST['item_number'];
$message .= "\Description:" . $_POST['title'];
$message .= "\________________________________________________________________";
}

//$message .= "\nName: " . $_POST['contactname'];
//$message .= "\nEmail: " . $_POST['contactemail'];
//$message .= "\nTelephone: " . $_POST['contactphone'];


$message .= "\nMessage: " . $_POST['contactmessage'];

//Receive Variable
$sentOk = mail($to,$subject,$message,$headers);
}
?>

<!-- END SEND MAIL SCRIPT -->
<!--End Submission Form -->
<!--END SUBMIT ORDER PART TWO -->

Rusty

Re: [Jason] Using Website Favorites as Order Submission

By Rusty - January 26, 2011 - edited: January 26, 2011

The concatenation operator fixed the error messages, however the email that's being generated are still coming through blank.

I can't seem to get to the variable to pull up properly.

<!-- START SEND MAIL SCRIPT -->
<div id="done">
<h2>Order Successfully Submitted!</h2>
<p>Your order has been placed.<br/ >
Thank you for your business, should you have any questions please call us at 503-649-0168.</p>
</div>
<?php error_reporting( E_ALL & ~E_NOTICE );
$mail = $_POST['email'];


$to = "rusty@website.com";
$subject = "New Order from Website";
$headers = "From: Website <noreply@website.com>";
$message = "Sent from the Website\n";
//$message .= "\nName: " . $_POST['contactname'];
//$message .= "\nEmail: " . $_POST['contactemail'];
//$message .= "\nTelephone: " . $_POST['contactphone'];

foreach ($favoriteRecords as $record) {
$message .= "\n________________________________________________________________";
This part works great with concatenation
If I just have $message .= "\nQuantity:" . $qty_string;
The form will email the item number with _qty appended to it
something like 987654_qty

$qty_string = $record['item_number'] . "_qty";
This is where I was having issues.
I got it working by removing the '' Single Quotes within the brackets
I can dynamically call up the joined item number quantity with this

$message .= "\nQuantity:" . $_POST[$qty_string];

$message .= "\nItem Number:" . $record['item_number'];
$message .= "\nDescription:" . $record['title'];

}

$message .= "\nMessage: " . $_POST['contactmessage'];

//Receive Variable
$sentOk = mail($to,$subject,$message,$headers);
}
?>
<!-- END SEND MAIL SCRIPT -->

Rusty

Re: [Rusty] Using Website Favorites as Order Submission

By Jason - January 26, 2011

Hi Rusty,

Glad to hear you got that sorted out. Let me know if you run into any other issues.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/