koollayed Posted July 8, 2010 Posted July 8, 2010 I had a question. I was wondering if the Oscommerce community could help. I was trying to pull the product_url from the product info page into the confirmation email sent to the customer. It is the data that is put in on the admin side and shows "Webpage" on the product info page. I wanted to pull that unique web url in the customers confirmation email. I'm very stuck with this and was wondering if you could help me. It would be very appreciated. The closest I have seen is gender information being pulled and customer email. I'm not really good with pulling information from the database. Any help would really be appreciated. Thanks
web-project Posted July 9, 2010 Posted July 9, 2010 can be done, you will update the SQL which used in checkout_process.php file to add extra text and URL to product. Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here! 8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself. Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues. Any issues with oscommerce, I am here to help you.
♥ecartz Posted July 9, 2010 Posted July 9, 2010 I was trying to pull the product_url from the product info page into the confirmation email sent to the customer. It is the data that is put in on the admin side and shows "Webpage" on the product info page. I wanted to pull that unique web url in the customers confirmation email.In the get_products function in includes/classes/shopping_cart.php, there is a line that looks something like $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); Add the products_url to it like $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id, pd.products_url from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); Further down, there is a section that looks something like $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '')); Add a new line like $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'url' => $products['products_url'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '')); Then in includes/classes/order.php find code like $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']), 'weight' => $products[$i]['weight'], 'id' => $products[$i]['id']); and add a url field to it like $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'url' => $products[$i]['url'], 'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']), 'weight' => $products[$i]['weight'], 'id' => $products[$i]['id']); Then in checkout_process.php find code like $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"; and modify it to include $order->products[$i]['url'] where you want the URL to appear. Always back up before making changes.
koollayed Posted July 10, 2010 Author Posted July 10, 2010 In the get_products function in includes/classes/shopping_cart.php, there is a line that looks something like $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); Add the products_url to it like $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id, pd.products_url from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); Further down, there is a section that looks something like $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '')); Add a new line like $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'url' => $products['products_url'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '')); Then in includes/classes/order.php find code like $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']), 'weight' => $products[$i]['weight'], 'id' => $products[$i]['id']); and add a url field to it like $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'url' => $products[$i]['url'], 'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']), 'weight' => $products[$i]['weight'], 'id' => $products[$i]['id']); Then in checkout_process.php find code like $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"; and modify it to include $order->products[$i]['url'] where you want the URL to appear. Thanks so much this worked in the product side of the email. If I wanted to move it to the head of the email and say "Go to here (product_url) to see the page." how would I go about doing that. Thanks alot again.
♥ecartz Posted July 12, 2010 Posted July 12, 2010 Could you write out how an email looks now and how you want it to look? Preferably on an order with at least two products with URLs. Three or more might be better. Always back up before making changes.
koollayed Posted July 14, 2010 Author Posted July 14, 2010 Could you write out how an email looks now and how you want it to look? Preferably on an order with at least two products with URLs. Three or more might be better. Right now I have it like Dear Ryan Cole Thank you for choosing (my site). Please visit the link below under products. ------------------------------------------------------ Order Number: 147 Date Ordered: Saturday 10 July, 2010 Ticket Information ------------------------------------------------------ This is your url -----> (product_url) 1 x ticket () = $35.00 ------------------------------------------------------ Sub-Total: $35.00 Flat Rate (Best Way): $5.00 Total: $40.00 - Hide quoted text - Delivery Address ------------------------------------------------------ guest address Telephone: 407-555-5555 Billing Address ------------------------------------------------------ guest address Telephone: 407-555-5555 Payment Method ------------------------------------------------------ Credit Card I want it to read like Dear Guest Thank you for choosing site. Please visit (product_url), (product_url) and (product_url). ------------------------------------------------------ Order Number: 113 Date Ordered: Friday 09 July, 2010 Products ------------------------------------------------------ 1 x test () = $0.00 ------------------------------------------------------ Sub-Total: $25.00 Flat Rate (Best Way): $5.00 Total: $30.00 Delivery Address ------------------------------------------------------ guest addressed Telephone: 407-555-5555 Billing Address ------------------------------------------------------ guest addressed Telephone: 407-555-5555 Payment Method ------------------------------------------------------ Credit Card I wanted the product_url to be added in the head of the email. It seems like the product_url has to stay in the product section of the email. Thanks
♥ecartz Posted July 15, 2010 Posted July 15, 2010 In checkout_process.php fine code that looks like // initialized for the email confirmation $products_ordered = ''; $subtotal = 0; $total_tax = 0; for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { and add a line like // initialized for the email confirmation $products_ordered = ''; $subtotal = 0; $total_tax = 0; $product_urls = array(); for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { Find the previous line that I suggested changing $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"; and just before it put if (tep_not_null($order->products[$i]['url'])) $product_urls[] = $order->products[$i]['url']; Then you can add the product URLs to the head of the email using the $product_urls variable. Generally a list is easier to generate than a sentence (fewer odd grammatical rules in lists). Always back up before making changes.
koollayed Posted July 16, 2010 Author Posted July 16, 2010 In checkout_process.php fine code that looks like // initialized for the email confirmation $products_ordered = ''; $subtotal = 0; $total_tax = 0; for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { and add a line like // initialized for the email confirmation $products_ordered = ''; $subtotal = 0; $total_tax = 0; $product_urls = array(); for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { Find the previous line that I suggested changing $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"; and just before it put if (tep_not_null($order->products[$i]['url'])) $product_urls[] = $order->products[$i]['url']; Then you can add the product URLs to the head of the email using the $product_urls variable. Generally a list is easier to generate than a sentence (fewer odd grammatical rules in lists). Thanks again. I added the code after EMAIL_TEXT_GREETING the and when I put in the code it says "Array" and not the url in the email when I add the $product_urls code. Is there away to fix it or another way to add the code to a sentence in the greeting part of the email. My code for the section is: //------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 .= EMAIL_TEXT_CUSTOMER_GREETING_TIX . $order->products[$i]['url'] . "\n"; if (tep_not_null($order->products[$i]['url'])) $product_urls[] = $order->products[$i]['url']; $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"; } // lets start with the email confirmation //BOF Multimixer 21.6.09 //$email_order = STORE_NAME . "\n\n" . $email_order .= EMAIL_TEXT_CUSTOMER_GREETING . ' ' . $order->customer['firstname'] . ' ' . $order->customer['lastname'] . "\n\n". EMAIL_TEXT_GREETING . ' ' . $product_urls . "\n" . //EOF Multimixer 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) . "\n\n"; $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered . EMAIL_SEPARATOR . "\n"; Thanks
Recommended Posts
Archived
This topic is now archived and is closed to further replies.