shipped status

2 views
Skip to first unread message

jasdix

unread,
May 19, 2009, 9:08:02 AM5/19/09
to phpShop
Hi,

does anyone have the code from the old php shop forum for the file

"ps_orde.inc" which when you change the status from confirmed to
shipped it sends an automatic email to the client

thanks to anyone who can post it up

Jeff Newman

unread,
May 19, 2009, 9:39:55 AM5/19/09
to php...@googlegroups.com
i created a quick version of it from the existing email function. this one
only sends an email to the customer, and it's an abbreviated recap of the
order, with the change in status listed as such.

add this function to the end of ps_order.inc:

[code]
/**************************************************************************
** name: email_order_status()
** created by: jnewman67 from gday's version for order creation.
** description: email the current status of an order to the customer.
** parameters: $order_id - Order ID for which to create the email receipts
** returns: True - email created and sent
** False - error occured
***************************************************************************/
function email_order_status($order_id) {
global $sess,
$ps_product,
$ps_vendor_id;

require_once("product/lib/ps_product.inc");
$ps_product = new ps_product;


// Connect to database and gather appropriate order information
$db = new ps_DB;
$q = "SELECT * FROM orders ";
$q .= "WHERE order_id='$order_id'";
$db->query($q);
$db->next_record();
$user_id = $db->f("user_id");

$dbbt = new ps_DB;
$qt = "SELECT * from user_info ";
$qt .= "WHERE user_info.user_id='$user_id' ";
$qt .= "AND user_info.address_type='BT'";
$dbbt->query($qt);
$dbbt->next_record();

$dbst = new ps_DB;
$qt = "SELECT * FROM user_info ";
$qt .= "WHERE user_info_id='";
$qt .= $db->f("user_info_id") . "'";
$dbst->query($qt);
$dbst->next_record();

$dbv = new ps_DB;
$qt = "SELECT * from vendor ";
/* Need to decide on vendor_id <=> order relationship */
$qt .= "WHERE vendor_id = $ps_vendor_id";
$dbv->query($qt);
$dbv->next_record();


// Email Addresses for shopper and vendor
// **************************************
$shopper_email = $dbbt->f("user_email");
$from_email = $dbv->f("contact_email");


// Headers and Footers
// ******************************
// Shopper Header
$shopper_header = "Thank you for shopping with us. Your order ";
$shopper_header .= "information follows.\n\n";

//Shopper Footer
$shopper_footer = "\n\nThank you for your patronage.\n";
$shopper_footer .= "\n\nQuestions? Problems?\n";
$shopper_footer .= "Email: " . $dbv->f("contact_email");

$shopper_subject = $dbv->f("vendor_name") . " Order -" .
$db->f("order_id");

// Main Email Message Purchase Order
// *********************************
$shopper_message = "ORDER STATUS CHANGE\n";
$shopper_message .=
"------------------------------------------------------------------------\n";
$shopper_message .= "ORDER NUMBER: " . $db->f("order_id") . "\n";
$shopper_message .= "ORDER DATE: ";
$shopper_message .= date("d-M-Y:H:i", $db->f("cdate")) . "\n\n";
$shopper_message .= "ORDER STATUS: ";
switch($db->f("order_status")) {
case ("P"):
$shopper_message .= "Pending\n\n";
break;
case ("X"):
$shopper_message .= "Canceled\n\n";
break;
case ("C"):
$shopper_message .= "Confirmed\n\n";
break;
}
$shopper_message .= "ORDER ITEMS\n";
$shopper_message .= "-----------";

$dboi = new ps_DB;
$q = "SELECT * ";
$q .= "FROM product, order_item, orders ";
$q .= "WHERE product.product_id=order_item.product_id ";
$q .= "AND order_item.order_id='";
$q .= $order_id . "' ";
$q .= "AND orders.order_id=order_item.order_id";
$dboi->query($q);

while($dboi->next_record()) {
$shopper_message .= "\n\n";
$shopper_message .= "PRODUCT = ";
if ($dboi->f("product_parent_id")) {
$shopper_message .=
$ps_product->get_field($dboi->f("product_parent_id"), "product_name") .
"\n";
$shopper_message .= "SERVICE = ";
}
$shopper_message .= $dboi->f("product_name") . "\n";
$shopper_message .= "QUANTITY = ";
$shopper_message .= $dboi->f("product_quantity") . "\n";
$shopper_message .= "SKU = ";
$shopper_message .= $ps_product->get_field($dboi->f("product_id"),
"product_sku") . "\n";
$price = $ps_product->get_price($dboi->f("product_id"));
$shopper_message .= "PRICE = ";
$shopper_message .= sprintf("%1.2f %s", $price["product_price"],
$price["product_currency"]);
}

$shopper_message .= "\n\n";
$sub_total = $db->f("order_subtotal");
$shopper_message .= "SUBTOTAL = ";
$shopper_message .= sprintf("%1.2f %s\n", $sub_total,
$price["product_currency"]);
$order_tax = $db->f("order_tax");
$shopper_message .= "TAX = ";
$shopper_message .= sprintf("%1.2f\n", $order_tax);

$order_shipping = $db->f("order_shipping");
$shopper_message .= "SHIPPING = ";
$shopper_message .= sprintf("%1.2f\n", $order_shipping);

$order_shipping_tax = $db->f("order_shipping_tax");
$shopper_message .= "SHIPPING TAX = ";
$shopper_message .= sprintf("%1.2f\n", $order_shipping_tax);

$order_total= $sub_total +
$order_tax +
$order_shipping +
$order_shipping_tax;
$shopper_message .= "\n\n";
$shopper_message .= "TOTAL = ";
$shopper_message .= sprintf("%1.2f %s\n", $order_total,
$price["product_currency"]);
$shopper_message .=
"------------------------------------------------------------------------\n";
// End of Purchase Order
// *********************

require_once("admin/lib/ps_mail.inc");
$ps_mail = new ps_mail;

// Mail receipt to the shopper
$ps_mail->send($shopper_email,
$shopper_subject,
$shopper_header . $shopper_message . $shopper_footer,
$from_email);

return(True);
}
[/code]

and add this function call to the order_status_update function, just before
the "return" statement:

[code]
$this->email_order_status ($d["order_id"]);
[/code]

the email sent lists the order specifics (date, time, number, and purchase
info), but skips all the customer specific info (shipping and billing info).
and no copy is created or sent to the vendor (as they just did the update,
so they would know!).

let me know if you find any issues.
--------------------------------------------------------------------------------



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.339 / Virus Database: 270.12.34/2122 - Release Date: 05/19/09
06:21:00

Reply all
Reply to author
Forward
0 new messages