WhoNu Posted July 19, 2008 Posted July 19, 2008 The extra order emails which are sent to our order processors display the product name and the product model. I need to add the product's stock id to this email so the orders can interface with our internal software. If possible, I would like to do this without the customer seeing the stock id in their email. Any help on this would be greatly appreciated.
germ Posted July 19, 2008 Posted July 19, 2008 What field in the DB is the product's stock id stored in? :unsure: All you'll need to do is build two different part to the email (just the $products_ordered part), one with the stock id to send to the order processor, and one without it to send to the customer. If you can tell me what DB field it's in I can probably cook something up for you. :) If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
WhoNu Posted July 19, 2008 Author Posted July 19, 2008 Thanks! :) The field is named 'stock_id' in the products database table. What field in the DB is the product's stock id stored in?:unsure: All you'll need to do is build two different part to the email (just the $products_ordered part), one with the stock id to send to the order processor, and one without it to send to the customer. If you can tell me what DB field it's in I can probably cook something up for you. :)
germ Posted July 19, 2008 Posted July 19, 2008 MAKE A BACKUP OF THIS FILE BEFORE MAKING ANY EDITS. All these changes take place in /catalog/checkout_process.php Find this code: // initialized for the email confirmation $products_ordered = ''; Replace it with: // initialized for the email confirmation $products_ordered = ''; $products_ordered_with_stock_id = ''; Find this code: $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; Replace it with: $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; $products_ordered_with_stock_id .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ' Stock ID = ' . $order->products[$i]['stock_id'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; Find this code: $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered . EMAIL_SEPARATOR . "\n"; for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { $email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n"; } if ($order->content_type != 'virtual') { $email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n"; } $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n"; if (is_object($$payment)) { $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . EMAIL_SEPARATOR . "\n"; $payment_class = $$payment; $email_order .= $payment_class->title . "\n\n"; if ($payment_class->email_footer) { $email_order .= $payment_class->email_footer . "\n\n"; } } tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); // send emails to other people if (SEND_EXTRA_ORDER_EMAILS_TO != '') { tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } Replace it with: $email_order_with_stock_id = $email_order; $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered . EMAIL_SEPARATOR . "\n"; $email_order_with_stock_id .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered_with_stock_id . EMAIL_SEPARATOR . "\n"; for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { $email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n"; $email_order_with_stock_id .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n"; } if ($order->content_type != 'virtual') { $email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n"; $email_order_with_stock_id .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n"; } $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n"; $email_order_with_stock_id .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n"; if (is_object($$payment)) { $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . EMAIL_SEPARATOR . "\n"; $email_order_with_stock_id .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . EMAIL_SEPARATOR . "\n"; $payment_class = $$payment; $email_order .= $payment_class->title . "\n\n"; $email_order_with_stock_id .= $payment_class->title . "\n\n"; if ($payment_class->email_footer) { $email_order .= $payment_class->email_footer . "\n\n"; $email_order_with_stock_id .= $payment_class->email_footer . "\n\n"; } } tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); // send emails to other people if (SEND_EXTRA_ORDER_EMAILS_TO != '') { tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order_with_stock_id, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
WhoNu Posted July 26, 2008 Author Posted July 26, 2008 I could not find code to match the third section of your directions in the checkout_process.php file. $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered . EMAIL_SEPARATOR . "\n"; Not sure how to proceed. MAKE A BACKUP OF THIS FILE BEFORE MAKING ANY EDITS. All these changes take place in /catalog/checkout_process.php Find this code: // initialized for the email confirmation $products_ordered = ''; Replace it with: // initialized for the email confirmation $products_ordered = ''; $products_ordered_with_stock_id = ''; Find this code: $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; Replace it with: $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; $products_ordered_with_stock_id .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ' Stock ID = ' . $order->products[$i]['stock_id'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; Find this code: $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered . EMAIL_SEPARATOR . "\n"; for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { $email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n"; } if ($order->content_type != 'virtual') { $email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n"; } $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n"; if (is_object($$payment)) { $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . EMAIL_SEPARATOR . "\n"; $payment_class = $$payment; $email_order .= $payment_class->title . "\n\n"; if ($payment_class->email_footer) { $email_order .= $payment_class->email_footer . "\n\n"; } } tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); // send emails to other people if (SEND_EXTRA_ORDER_EMAILS_TO != '') { tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } Replace it with: $email_order_with_stock_id = $email_order; $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered . EMAIL_SEPARATOR . "\n"; $email_order_with_stock_id .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered_with_stock_id . EMAIL_SEPARATOR . "\n"; for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { $email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n"; $email_order_with_stock_id .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n"; } if ($order->content_type != 'virtual') { $email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n"; $email_order_with_stock_id .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n"; } $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n"; $email_order_with_stock_id .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n"; if (is_object($$payment)) { $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . EMAIL_SEPARATOR . "\n"; $email_order_with_stock_id .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . EMAIL_SEPARATOR . "\n"; $payment_class = $$payment; $email_order .= $payment_class->title . "\n\n"; $email_order_with_stock_id .= $payment_class->title . "\n\n"; if ($payment_class->email_footer) { $email_order .= $payment_class->email_footer . "\n\n"; $email_order_with_stock_id .= $payment_class->email_footer . "\n\n"; } } tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); // send emails to other people if (SEND_EXTRA_ORDER_EMAILS_TO != '') { tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order_with_stock_id, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); }
germ Posted July 26, 2008 Posted July 26, 2008 Post the code from your file between CODE tags and I'll ad lib.... ;) If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
WhoNu Posted July 26, 2008 Author Posted July 26, 2008 <?php /* $Id: checkout_process.php,v 1.2.37.2 2004/01/01 14:00:29 Strider Exp $ $Id: checkout_process.php,v 1.128 2003/07/24 18:00:29 Strider Exp $ $Id: checkout_process.php,v 1.128 2003/05/28 18:00:29 hpdl Exp $ $Id: checkout_process.php,v 1.6.2.1 2003/05/03 23:41:23 wilt Exp $ osCommerce, Open Source E-Commerce Solutions I really appreciate this. Here's the file... http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ include('includes/application_top.php'); $pagetype='shop'; // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT)); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } if (!tep_session_is_registered('sendto')) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } if ( (tep_not_null(MODULE_PAYMENT_INSTALLED)) && (!tep_session_is_registered('payment')) ) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } // avoid hack attempts during the checkout procedure by checking the internal cartID if (isset($cart->cartID) && tep_session_is_registered('cartID')) { if ($cart->cartID != $cartID) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } } include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS); // load selected payment module require(DIR_WS_CLASSES . 'payment.php'); if ($credit_covers) $payment=''; //ICW added for CREDIT CLASS $payment_modules = new payment($payment); // load the selected shipping module require(DIR_WS_CLASSES . 'shipping.php'); $shipping_modules = new shipping($shipping); require(DIR_WS_CLASSES . 'order.php'); $order = new order; require(DIR_WS_CLASSES . 'order_total.php'); $order_total_modules = new order_total; $order_totals = $order_total_modules->process(); // load the before_process function from the payment modules $payment_modules->before_process(); $sql_data_array = array('customers_id' => $customer_id, 'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'customers_company' => $order->customer['company'], 'customers_street_address' => $order->customer['street_address'], 'customers_street_address2' => $order->customer['street_address2'], 'customers_suburb' => $order->customer['suburb'], 'customers_city' => $order->customer['city'], 'customers_postcode' => $order->customer['postcode'], 'customers_state' => $order->customer['state'], 'customers_country' => $order->customer['country']['title'], 'customers_telephone' => $order->customer['telephone'], 'customers_fax' =>$order->customer['fax'], 'customers_email_address' => $order->customer['email_address'], 'customers_address_format_id' => $order->customer['format_id'], 'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'], 'delivery_company' => $order->delivery['company'], 'delivery_street_address' => $order->delivery['street_address'], 'delivery_street_address2' => $order->delivery['street_address2'], 'delivery_suburb' => $order->delivery['suburb'], 'delivery_city' => $order->delivery['city'], 'delivery_postcode' => $order->delivery['postcode'], 'delivery_state' => $order->delivery['state'], 'delivery_country' => $order->delivery['country']['title'], 'delivery_telephone' => $order->delivery['telephone'], 'delivery_fax' =>$order->delivery['fax'], 'delivery_address_format_id' => $order->delivery['format_id'], 'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'], 'billing_company' => $order->billing['company'], 'billing_street_address' => $order->billing['street_address'], 'billing_street_address2' => $order->billing['street_address2'], 'billing_suburb' => $order->billing['suburb'], 'billing_city' => $order->billing['city'], 'billing_postcode' => $order->billing['postcode'], 'billing_state' => $order->billing['state'], 'billing_country' => $order->billing['country']['title'], 'billing_telephone' => $order->billing['telephone'], 'billing_fax' =>$order->billing['fax'], 'billing_address_format_id' => $order->billing['format_id'], 'payment_method' => $order->info['payment_method'], // 'cc_type' => $order->info['cc_type'], // 'cc_owner' => $order->info['cc_owner'], // 'cc_number' => substr($order->info['cc_number'],-4,4), // 'cc_expires' => $order->info['cc_expires'], 'po_number' => $order->info['po_number'], 'date_purchased' => 'now()', 'orders_status' => $order->info['order_status'], 'currency' => $order->info['currency'], 'currency_value' => $order->info['currency_value'], 'shipping_method'=>$order->info['shipping_method'], 'pickup_location' => $fflnumber); tep_db_perform(TABLE_ORDERS, $sql_data_array); $insert_id = tep_db_insert_id(); for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { $sql_data_array = array('orders_id' => $insert_id, 'title' => $order_totals[$i]['title'], 'text' => $order_totals[$i]['text'], 'value' => $order_totals[$i]['value'], 'class' => $order_totals[$i]['code'], 'sort_order' => $order_totals[$i]['sort_order']); tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); } $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0'; $sql_data_array = array('orders_id' => $insert_id, 'orders_status_id' => $order->info['order_status'], 'date_added' => 'now()', 'customer_notified' => $customer_notification, 'comments' => $order->info['comments']); tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array); // initialized for the email confirmation $products_ordered = ''; $subtotal = 0; $total_tax = 0; for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { // Stock Update - Joao Correia if (STOCK_LIMITED == 'true') { $products_attributes = $order->products[$i]['attributes']; // PK STOCK MOD START ob_start(); if (is_array($products_attributes)) { $products_stock_attributes_array = array(); echo "prod attr is array\n"; for($k=0, $n3=sizeof($products_attributes); $k<$n3; $k++){ if ($products_attributes[$k]['special'] == 0) { $products_stock_attributes_array[] = $products_attributes[$k]['option_id']."-".$products_attributes[$k]['value_id']; } } ksort($products_stock_attributes_array); reset($products_stock_attributes_array); $products_stock_attributes=implode(",",$products_stock_attributes_array); $psaa_str = '('; foreach($products_stock_attributes_array as $psaa) { $psaa_str .= "products_stock_attributes like '%$psaa%' and "; } $psaa_str .= '1)'; echo $products_stock_attributes . "\n"; $attributes_stock_query = tep_db_query("select products_stock_quantity,products_code,products_bin_number from " . TABLE_PRODUCTS_STOCK . " where $psaa_str AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); echo "query = " . "select products_stock_quantity,products_code,products_bin_number from " . TABLE_PRODUCTS_STOCK . " where $psaa_str AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"; $bin_number=''; $stock_id=''; if (tep_db_num_rows($attributes_stock_query) > 0) { $attributes_stock_values = tep_db_fetch_array($attributes_stock_query); $attributes_stock_left = $attributes_stock_values['products_stock_quantity'] - $order->products[$i]['qty']; echo "updating tables with $attributes_stock_left\n"; if ($attributes_stock_left < 1) { tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '0' where $psaa_str AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); $actual_stock_bought = $attributes_stock_values['products_stock_quantity']; }else{ tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '" . $attributes_stock_left . "' where $psaa_str AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); $actual_stock_bought = $order->products[$i]['qty']; } $bin_number=$attributes_stock_values['products_bin_number']; $stock_id=$attributes_stock_values['products_code']; }else{ $prod_stock=tep_db_fetch_array(tep_db_query("select bin_number, stock_id from " . TABLE_PRODUCTS . " where products_id= '" . tep_get_prid($order->products[$i]['id']) . "'")); $bin_number=$prod_stock['bin_number']; $stock_id=$prod_stock['stock_id']; $actual_stock_bought = $order->products[$i]['qty']; } }else{ $prod_stock=tep_db_fetch_array(tep_db_query("select bin_number, stock_id from " . TABLE_PRODUCTS . " where products_id= '" . tep_get_prid($order->products[$i]['id']) . "'")); $bin_number=$prod_stock['bin_number']; $stock_id=$prod_stock['stock_id']; $actual_stock_bought = $order->products[$i]['qty']; } $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); if (tep_db_num_rows($stock_query) > 0) { $stock_values = tep_db_fetch_array($stock_query); // do not decrement quantities if products_attributes_filename exists // if ((DOWNLOAD_ENABLED != 'false')) {//|| (!$stock_values['products_attributes_filename']) $stock_left = $stock_values['products_quantity'] - $actual_stock_bought; //echo "first mark"; // } else { // $stock_left = $stock_values['products_quantity']; // echo "seconf mark"; // } echo "UPDATING QTY's to $stock_left, $actual_stock_bought \n"; tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) { // pk status was set to 1 before // tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '2' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } } } //stock limited true if statement $s = ob_get_contents(); ob_end_clean(); // PK STOCK MOD END // Update products_ordered (for bestsellers list) tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); $sql_data_array = array('orders_id' => $insert_id, 'products_id' => tep_get_prid($order->products[$i]['id']), 'stock_id' => $order->products[$i]['stock_id'], 'products_name' => $order->products[$i]['name'], 'products_price' => $order->products[$i]['price'], 'final_price' => $order->products[$i]['final_price'], 'products_tax' => $order->products[$i]['tax'], 'products_quantity' => $order->products[$i]['qty'], 'bin_number' => $bin_number, 'stock_id' => $stock_id, 'required_headers_codes' => serialize($order->products[$i]['headers_confirmation']), ); tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array); $order_products_id = tep_db_insert_id(); $order_total_modules->update_credit_account($i);//ICW ADDED FOR CREDIT CLASS SYSTEM //------insert customer choosen option to order-------- $attributes_exist = '0'; $products_ordered_attributes = ''; if (isset($order->products[$i]['attributes'])) { $attributes_exist = '1'; for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) { if (DOWNLOAD_ENABLED == 'true') { $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad on pa.products_attributes_id=pad.products_attributes_id where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'"; $attributes = tep_db_query($attributes_query); } else { $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'"); } $attributes_values = tep_db_fetch_array($attributes); //daniel schonfeld 12/2005 //added to support TEXT option if (is_array($attributes_values)) { $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'products_options' => $attributes_values['products_options_name'], 'products_options_values' => $attributes_values['products_options_values_name'], 'options_values_price' => $attributes_values['options_values_price'], 'price_prefix' => $attributes_values['price_prefix']); } else { $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'products_options' => $order->products[$i]['attributes'][$j]['option'], 'products_options_values' => $order->products[$i]['attributes'][$j]['value'], 'options_values_price' => $order->products[$i]['attributes'][$j]['price'], 'price_prefix' => $order->products[$i]['attributes'][$j]['prefix']); } tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array); if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) { $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'orders_products_filename' => $attributes_values['products_attributes_filename'], 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 'download_count' => $attributes_values['products_attributes_maxcount']); tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array); } if (EMAIL_USE_HTML == 'true') { $products_ordered_attributes .= "<br> - " . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name']; }else{ $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name']; } } } //------insert customer choosen option eof ---- $total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']); $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty']; $total_cost += $total_products_price; $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n<br>"; } $order_total_modules->apply_credit();//ICW ADDED FOR CREDIT CLASS SYSTEM // lets start with the email confirmation $date_time = tep_db_datetime(); $email_order = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG, strtotime($date_time)) . "\n"; $eorder = array(); if ($order->info['comments']) { $email_order .= tep_db_output($order->info['comments']) . "\n\n"; $eorder['comments'] = tep_db_output($order->info['comments']) . "\n\n"; } $eorder['products'] = $products_ordered; $eorder['date_long'] = strftime(DATE_FORMAT_LONG); $eorder['order_totals'] = ''; for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { if (EMAIL_USE_HTML == 'true') { $eorder['order_totals'] .= $order_totals[$i]['title'] . ' ' . $order_totals[$i]['text'] . "<br>"; }else{ $eorder['order_totals'] .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n"; } } if (EMAIL_USE_HTML == 'true') { if ($order->content_type != 'virtual' && $order->content_type != 'virtual_weight') { $eorder['shipping_address'] = tep_address_label($customer_id, $sendto, 0, '', "<br>"); } }else{ if ($order->content_type != 'virtual' && $order->content_type != 'virtual_weight') { $eorder['shipping_address'] = tep_address_label($customer_id, $sendto, 0, '', "\n"); } } if (EMAIL_USE_HTML == 'true') { $eorder['billing_address'] = tep_address_label($customer_id, $billto, 0, '', "<br>") . "<br>" . $order->customer['telephone']; }else{ $eorder['billing_address'] = tep_address_label($customer_id, $billto, 0, '', "\n") . "\n" . $order->customer['telephone']; } $eorder['order_info_url'] = tep_href_link('account_history_info.php', 'order_id=' . $insert_id, 'SSL', false); $eorder['visible_id'] = $insert_id; //$visible_id; $ecustomer = array(); $ecustomer['first_name'] = $order->customer['firstname']; $ecustomer['last_name'] = $order->customer['lastname']; $ecustomer['email_address'] = $order->customer['email_address']; if(!tep_session_is_registered('customer_has_account')){ $no_register=1; $random_password=createRandomPassword(); $ecustomer['password']=$random_password; tep_db_query("update ".TABLE_CUSTOMERS." set create_account=1, customers_password='". tep_encrypt_password($random_password)."' where customers_id=".$customer_id); $customer_has_account=1; tep_session_register('customer_has_account'); //delete one week old customer not creating account $query=tep_db_query("select c.* ,ci.customers_info_date_account_created from ".TABLE_CUSTOMERS." c inner join ".TABLE_CUSTOMERS_INFO." ci on ci.customers_info_id=c.customers_id where create_account=0 and DATEDIFF(CURDATE(),ci.customers_info_date_account_created)>7"); if(tep_db_num_rows($query)){ while($r=tep_db_fetch_array($query)){ tep_db_query("delete from ".TABLE_ADDRESS_BOOK." where customers_id='".$r[customers_id]."'"); tep_db_query("delete from ".TABLE_CUSTOMERS_BASKET." where customers_id='".$r[customers_id]."'"); tep_db_query("delete from ".TABLE_CUSTOMERS_BASKET_ATTRIBUTES." where customers_id='".$r[customers_id]."'"); tep_db_query("delete from ".TABLE_CUSTOMERS_INFO." where customers_info_id='".$r[customers_id]."'"); tep_db_query("delete from ".TABLE_CUSTOMERS." where customers_id='".$r[customers_id]."'"); } } } if (is_object($$payment)) { $payment_class = $$payment; $eorder['payment_method'] = $payment_class->title; if ($payment_class->email_footer) { $eorder['payment_footer'] = ($payment_class->email_footer); } } if($fflnumber!='') { // $_pickup_location = tep_db_fetch_array(tep_db_query("select * from ffl where fflnum='" . $fflnumber . "'")); if(is_array($_pickup_location)) { $_pickup_location = ''; } else { $_pickup_location['fflnumber'] = $fflnumber; } $eorder['pickup_location'] = $_pickup_location; } $eorder['po_number'] = $order->info['po_number']; $ecustomer['no_reg']= $no_register; $smarty->assign("order", $eorder); $smarty->assign("customer", $ecustomer); $template = 'email_conf_complete.tpl'; $smarty->assign('httplink',HTTP_SERVER.DIR_WS_HTTP_CATALOG); $email_order = $smarty->fetch($template); $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer')); $mimemessage->add_raw_html($email_order); $mimemessage->build_message(); $mimemessage->send($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_TEXT_SUBJECT); //tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); // send emails to other people if (SEND_EXTRA_ORDER_EMAILS_TO != '') { $mimemessage->send('', SEND_EXTRA_ORDER_EMAILS_TO, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_TEXT_SUBJECT); //tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } // load the after_process function from the payment modules $payment_modules->after_process(); foreach ($cart->contents as $product_id => $arr) { if ($arr['registry_id']) { $query = "SELECT * FROM giftregistry WHERE registry_id='".$arr['registry_id']."'"; $rep = tep_db_query($query); if ($item = tep_db_fetch_array($rep)) { if (strpos($product_id,'@')) { $new_product_id = substr($product_id,0,strpos($product_id,'@')); } else { $new_product_id = $product_id; } $query = "UPDATE ". TABLE_GIFT_REGISTRY_PRODUCTS." SET rcvd=rcvd+'".$arr['qty']."' WHERE products_id='".$new_product_id."' AND customers_id=".$item['customers_id']; tep_db_query($query); $query = "INSERT giftregistry_orders SET products_id='".$new_product_id."',registry_id=".$arr['registry_id'].", orders_id=".$insert_id.", creation_date='".date('Y-m-d H:i:s')."'"; tep_db_query($query); } } } $cart->reset(true); // unregister session variables used during checkout tep_session_unregister('sendto'); tep_session_unregister('billto'); tep_session_unregister('shipping'); tep_session_unregister('payment'); tep_session_unregister('comments'); tep_session_unregister('fflnumber'); if(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers'); $order_total_modules->clear_posts();//ICW ADDED FOR CREDIT CLASS SYSTEM tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL')); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Post the code from your file between CODE tags and I'll ad lib.... ;)
germ Posted July 26, 2008 Posted July 26, 2008 From looking at the code, I would hazard a guess thet you have a "Smarty Template" in use. I don't know how that code works. Basically what you need to do is construct two emails. One WITH the stock id embedded and one WITHOUT. Send the "without" one to the customer, and the "with" one to yourself. Since I don't know how the "Smarty" code works, I'd just screw your page up most likely. I really don't want to do that, and I'm sure you wouldn't want that either. :blush: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
dubz99 Posted August 4, 2008 Posted August 4, 2008 Jim, For those of us who are not using a "Smarty Template" would you be able to help?? I am looking to perform a similar action as the author of this post. If I post the code can you 'add lib' for me? I would really appreciate it! To make it easier on you we can use the same 'stock_id' example as stated above. Thanks dubz From looking at the code, I would hazard a guess thet you have a "Smarty Template" in use. I don't know how that code works. Basically what you need to do is construct two emails. One WITH the stock id embedded and one WITHOUT. Send the "without" one to the customer, and the "with" one to yourself. Since I don't know how the "Smarty" code works, I'd just screw your page up most likely. I really don't want to do that, and I'm sure you wouldn't want that either. :blush:
germ Posted August 4, 2008 Posted August 4, 2008 If you're using "out of the box" osC you should be able to use what I posted in post #4 in this thread. :) If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
dubz99 Posted August 7, 2008 Posted August 7, 2008 Germ, I am using an out of the box osC and was able to input other items into the e-mail that were already defined in the file, but how would I go about adding an item(variable from the table) that is not defined? For example I would like to add quantity in stock the e-mail sent to me. This is defined in the products_stock->products_code. How can I call the value from the file??? I have tried some variations and the result is nothing displays, which makes me think what I am calling has no value. Your help is much appreciated, it seems your a legend around here so I figured you'd be the person to talk to! Thanks dubz99 If you're using "out of the box" osC you should be able to use what I posted in post #4 in this thread. :)
germ Posted August 7, 2008 Posted August 7, 2008 For example I would like to add quantity in stock the e-mail sent to me Find this code: $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; Replace it with: $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; $products_ordered_with_stock_id .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ' Stock ID = ' . $order->products[$i]['stock_id'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . ' ( Qty. in stock = ' . tep_get_products_stock($order->products[$i]['id']) . ' )' . "\n"; If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
dubz99 Posted August 8, 2008 Posted August 8, 2008 Beautiful! What about the bin_number located in 'products_stock'->'products_bin_number' ?? Again thanks in advance! dubz Find this code: $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; Replace it with: $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; $products_ordered_with_stock_id .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ' Stock ID = ' . $order->products[$i]['stock_id'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . ' ( Qty. in stock = ' . tep_get_products_stock($order->products[$i]['id']) . ' )' . "\n";
germ Posted August 8, 2008 Posted August 8, 2008 I can't do that one. I don't have 'products_stock' nor 'products_bin_number' in any of my code. I'm usually "fair to partly cloudy" with PHP code, but frankly I can't even spell MYSQL... :blush: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
dubz99 Posted August 9, 2008 Posted August 9, 2008 Well thanks for your help on the other stuff. Basically I am trying to figure out how to pull any information for a particular product into the email notification. We are in the process of integrating osC with our accounting software and I'd like to have as much information in as we can get. Maybe there is a better way of doing it but currently we are just extracting fields from the e-mail confirmation. Can anyone else help?? dubz I can't do that one. I don't have 'products_stock' nor 'products_bin_number' in any of my code. I'm usually "fair to partly cloudy" with PHP code, but frankly I can't even spell MYSQL... :blush:
Recommended Posts
Archived
This topic is now archived and is closed to further replies.