Forums / General Questions / how to show product links on confirmation page?

how to show product links on confirmation page?

Locked

Views: 2,522

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
29 Sep 2006, 4:44 PM
#1
making_web2002 avatar

making_web2002

New Zenner

Join Date:
Sep 2006
Posts:
9
Plugin Contributions:
0

how to show product links on confirmation page?

Hi DrByte,

How you doing? i want to show products url in the checkout confirmation page.

i do not mean descriptive page urls,i mean "more info page urls".

I know products url will be in the products_description table in SQL.

I have checked it.

But i do not know the code to call that url in the checkout confirmation page.

i wanna show order quantity, products name ,price and also product url.

could you help me in this?

if you can give me the code,i can write it at tpl_checkout_confirmation_default.php.

iam new to php and sql.please give me the code .

Thank you very much

Jeethoo

29 Sep 2006, 5:22 PM
#2
making_web2002 avatar

making_web2002

New Zenner

Join Date:
Sep 2006
Posts:
9
Plugin Contributions:
0

Re: how to show product links on confirmation page?

can anyone help me ?

Thanks
Jeethoo

1 Oct 2006, 12:19 PM
#3
making_web2002 avatar

making_web2002

New Zenner

Join Date:
Sep 2006
Posts:
9
Plugin Contributions:
0

Re: how to show product links on confirmation page?

can anyone comeup with an idea?

i have been trying and trying ...but unsuccessful.

Thanks
Jeethoo

1 Oct 2006, 12:37 PM
#4
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: how to show product links on confirmation page?

making_web2002:

can anyone comeup with an idea?

i have been trying and trying ...but unsuccessful.

Thanks
Jeethoo
What did you try till now?

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

1 Oct 2006, 1:15 PM
#5
making_web2002 avatar

making_web2002

New Zenner

Join Date:
Sep 2006
Posts:
9
Plugin Contributions:
0

Re: how to show product links on confirmation page?

superprg:

What did you try till now?

here i will explain you what i did.

visitor after coming to confirmation page,he sees his order details.let say he order sony camc one unit for $299.99.

what he sees here is

Qty. Item Name Total
1 X sony cam 299.99

when i go to the source of the confirmation page,i have seen these are retrived from the TABLE_ORDERS_PRODUCTS .(this work is done by includes/classes/order.php)

in the confirmation source i have seen there is a loop, in the case the visitor order more products i.e different kind products.

he loop will work to retrieve all product names and qty and total.

uptill here everything is fine.

in this loop i entered this code <?php

echo $order->url[$i]['products_url'];

?>

The above code will try to contact the order.php where i have written another code which will contact the TABLE_PRODUCTS_DESCRIPTION to get the products_url.

here is that code which i have written.

(the bellow code should be in includes/classes/order.php)

i am pasting all the code here the red color one is i have newely written.i am shortening the code,because this form is not allow too long message

<?php function order($order_id = '') { $this->info = array(); $this->totals = array(); $this->products = array(); $this->customer = array(); $this->delivery = array(); $this->url = array(); code will go on ,nothing chaged here-------------uptill the below. $orders_products_query = "select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price, onetime_charges, products_priced_by_attribute, product_is_free, products_discount_type, products_discount_type_from from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"; $orders_products = $db->Execute($orders_products_query); $orders_url_query = "select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_name = '" . $orders_products->fields['products_name'] . "'"; $orders_url = $db->Execute($orders_url_query); while (!$orders_products->EOF) { // convert quantity to proper decimals - account history if (QUANTITY_DECIMALS != 0) { $fix_qty = $orders_products->fields['products_quantity']; switch (true) { case (!strstr($fix_qty, '.')): $new_qty = $fix_qty; break; default: $new_qty = preg_replace('/[0]+$/', '', $orders_products->fields['products_quantity']); break; } } else { $new_qty = $orders_products->fields['products_quantity']; } $new_qty = round($new_qty, QUANTITY_DECIMALS); if ($new_qty == (int)$new_qty) { $new_qty = (int)$new_qty; } $this->products[$index] = array('qty' => $new_qty, 'id' => $orders_products->fields['products_id'], 'name' => $orders_products->fields['products_name'], 'model' => $orders_products->fields['products_model'], 'tax' => $orders_products->fields['products_tax'], 'price' => $orders_products->fields['products_price'], 'final_price' => $orders_products->fields['final_price'], 'onetime_charges' => $orders_products->fields['onetime_charges'], 'products_priced_by_attribute' => $orders_products->fields['products_priced_by_attribute'], 'product_is_free' => $orders_products->fields['product_is_free'], 'products_discount_type' => $orders_products->fields['products_discount_type'], 'products_discount_type_from' => $orders_products->fields['products_discount_type_from']); $subindex = 0; $this->url[$index] = array('products_url' => $orders_url->fields['products_url']); $subindex = 0; $attributes_query = "select products_options_id, products_options_values_id, products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products->fields['orders_products_id'] . "'"; code goes on uptill the end ------ after i have done this ,nothing is showing up in the confirmation page. any help? thanks jeethoo
1 Oct 2006, 1:28 PM
#6
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: how to show product links on confirmation page?

Let me get back to you after trying this
San

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

1 Oct 2006, 5:42 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: how to show product links on confirmation page?

Here's the fastest way to do it without affecting core code:

new file:
/includes/functions/extra_functions/myfunctions.php

<?php 
  function zen_get_products_url($product_id, $language = '') {
    global $db;
    if (empty($language)) $language = $_SESSION['languages_id'];
    $product_query = "select products_url
                      from " . TABLE_PRODUCTS_DESCRIPTION . "
                      where products_id = '" . (int)$product_id . "'
                      and language_id = '" . (int)$language . "'";
    $product = $db->Execute($product_query);
    if ($product->fields['products_url'] == '') return false;
    $url = zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product->fields['products_url']), 'NONSSL', true, false);
    return '<a href="' . $url . '" target="_blank">' . MORE_INFO_TEXT . '</a>';
  }

?>

Now edit your checkout-confirmation template:
/includes/templates/YOURTEMPLATE/templates/tpl_checkout_confirmation_default.php
around line 134 you have this:<?php echo $stock_check[$i]; ?>add this below it:```
<?php if ($disp_url = zen_get_products_url($order->products[$i]['id']) ) echo '<br />' . $disp_url; ?>

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

2 Oct 2006, 12:10 PM
#8
making_web2002 avatar

making_web2002

New Zenner

Join Date:
Sep 2006
Posts:
9
Plugin Contributions:
0

Re: how to show product links on confirmation page?

DrByte:

Here's the fastest way to do it without affecting core code:

new file:
/includes/functions/extra_functions/myfunctions.php

<?php function zen_get_products_url($product_id, $language = '') { global $db; if (empty($language)) $language = $_SESSION['languages_id']; $product_query = "select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language . "'"; $product = $db->Execute($product_query); if ($product->fields['products_url'] == '') return false; $url = zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product->fields['products_url']), 'NONSSL', true, false); return '<a href="' . $url . '" target="_blank">' . MORE_INFO_TEXT . '</a>'; } ?>
> 
> Now edit your checkout-confirmation template:
> /includes/templates/YOURTEMPLATE/templates/tpl_checkout_confirmation_default.php
> around line 134 you have this:```
          <?php  echo $stock_check[$i]; ?>
```add this below it:```
          <?php if ($disp_url = zen_get_products_url($order->products[$i]['id']) )  echo '<br />' . $disp_url; ?>

After writing this code in the includes/functions/extra_functions/myfunctions.php,

iam getting the bellow error on each page while i browse including home page.

this bellow error is show very starting of the page.

here is the error.

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/jeethoo/public_html/store/includes/functions/extra_functions/myfunctions.php:18) in /home/ajit123/public_html/store/includes/functions/sessions.php on line 100

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/jeethoo/public_html/store/includes/functions/extra_functions/myfunctions.php:18) in /home/ajit123/public_html/store/includes/functions/sessions.php on line 100

Warning: Cannot modify header information - headers already sent by (output started at /home/jeethoo/public_html/store/includes/functions/extra_functions/myfunctions.php:18) in /home/jeethoo/public_html/store/includes/init_includes/init_templates.php on line 78


if the visitor come to the site and add the products to cart and login ,there are even more such errors are seen.

can you please tell me how to rectify this error.

my zen version 1.3.0.2

Thanks
Jeethoo

2 Oct 2006, 12:12 PM
#9
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: how to show product links on confirmation page?

In your myfunctions.php make sure that you dont have anything before

<?php and anything after ?>

San

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

2 Oct 2006, 12:25 PM
#10
making_web2002 avatar

making_web2002

New Zenner

Join Date:
Sep 2006
Posts:
9
Plugin Contributions:
0

Re: how to show product links on confirmation page?

superprg:

In your myfunctions.php make sure that you dont have anything before

<?php and anything after ?>

San

Yes nothing is there after and before that code.i even deleted free space and tried.But still same problem.

any help?

Thanks
Jeethoo

2 Oct 2006, 12:30 PM
#11
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: how to show product links on confirmation page?

What do you have in /home/ajit123/public_html/store/includes/functions/sessions.php on line 100?

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

2 Oct 2006, 12:38 PM
#12
making_web2002 avatar

making_web2002

New Zenner

Join Date:
Sep 2006
Posts:
9
Plugin Contributions:
0

Re: how to show product links on confirmation page?

superprg:

What do you have in /home/ajit123/public_html/store/includes/functions/sessions.php on line 100?

i do not know how to look 100th line in my code.my browser is counting the line in defferent way ,i think.i will paste all the file code here.

<?php /** * functions/sessions.php * Session functions * * @package functions * @copyright Copyright 2003-2005 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: sessions.php 3772 2006-06-13 18:51:58Z wilt $ */ if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } if (STORE_SESSIONS == 'db') { if (defined('DIR_WS_ADMIN')) { if (!$SESS_LIFE = (SESSION_TIMEOUT_ADMIN + 900)) { $SESS_LIFE = (SESSION_TIMEOUT_ADMIN + 900); } } else { if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) { $SESS_LIFE = 1440; } } function _sess_open($save_path, $session_name) { return true; } function _sess_close() { return true; } function _sess_read($key) { global $db; $qid = "select value from " . TABLE_SESSIONS . " where sesskey = '" . zen_db_input($key) . "' and expiry > '" . time() . "'"; $value = $db->Execute($qid); if (isset($value->fields['value']) && $value->fields['value']) { return $value->fields['value']; } return (""); } function _sess_write($key, $val) { global $db; global $SESS_LIFE; $expiry = time() + $SESS_LIFE; $value = $val; $qid = "select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . zen_db_input($key) . "'"; $total = $db->Execute($qid); if ($total->fields['total'] > 0) { $sql = "update " . TABLE_SESSIONS . " set expiry = '" . zen_db_input($expiry) . "', value = '" . zen_db_input($value) . "' where sesskey = '" . zen_db_input($key) . "'"; return $db->Execute($sql); } else { $sql = "insert into " . TABLE_SESSIONS . " values ('" . zen_db_input($key) . "', '" . zen_db_input($expiry) . "', '" . zen_db_input($value) . "')"; return $db->Execute($sql); } } function _sess_destroy($key) { global $db; $sql = "delete from " . TABLE_SESSIONS . " where sesskey = '" . zen_db_input($key) . "'"; return $db->Execute($sql); } function _sess_gc($maxlifetime) { global $db; $sql = "delete from " . TABLE_SESSIONS . " where expiry < '" . time() . "'"; $db->Execute($sql); return true; } session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc'); } function zen_session_start() { if (defined('DIR_WS_ADMIN')) { @ini_set('session.gc_maxlifetime', (SESSION_TIMEOUT_ADMIN < 900 ? (SESSION_TIMEOUT_ADMIN + 900) : SESSION_TIMEOUT_ADMIN)); } return session_start(); } function zen_session_register($variable) { die('This function has been deprecated. Please use Register Globals Off compatible code'); } function zen_session_is_registered($variable) { die('This function has been deprecated. Please use Register Globals Off compatible code'); } function zen_session_unregister($variable) { die('This function has been deprecated. Please use Register Globals Off compatible code'); } function zen_session_id($sessid = '') { if (!empty($sessid)) { return session_id($sessid); } else { return session_id(); } } function zen_session_name($name = '') { if (!empty($name)) { return session_name($name); } else { return session_name(); } } function zen_session_close() { if (function_exists('session_close')) { return session_close(); } } function zen_session_destroy() { return session_destroy(); } function zen_session_save_path($path = '') { if (!empty($path)) { return session_save_path($path); } else { return session_save_path(); } } function zen_session_recreate() { global $http_domain, $https_domain, $current_domain; if ($http_domain == $https_domain) { $saveSession = $_SESSION; $oldSessID = session_id(); session_regenerate_id(); $newSessID = session_id(); session_id($oldSessID); session_id($newSessID); if (STORE_SESSIONS == 'db') { session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc'); } session_start(); $_SESSION = $saveSession; whos_online_session_recreate($oldSessID, $newSessID); } else { /* $saveSession = $_SESSION; $oldSessID = session_id(); session_regenerate_id(); $newSessID = session_id(); session_id($oldSessID); session_destroy(); session_id($newSessID); session_set_cookie_params(0, '/', (zen_not_null($http_domain) ? $http_domain : '')); session_id($newSessID); if (STORE_SESSIONS == 'db') { session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc'); } session_start(); session_set_cookie_params(0, '/', (zen_not_null($current_domain) ? $current_domain : '')); session_start(); $_SESSION = $saveSession; */ } } ?>
2 Oct 2006, 7:06 PM
#13
making_web2002 avatar

making_web2002

New Zenner

Join Date:
Sep 2006
Posts:
9
Plugin Contributions:
0

Re: how to show product links on confirmation page?

hi Drbyte and Superprg,

have you checked this error? kindly helpme in this.i have no clue about this error.

Thanks
Jeethoo

3 Oct 2006, 1:39 AM
#14
making_web2002 avatar

making_web2002

New Zenner

Join Date:
Sep 2006
Posts:
9
Plugin Contributions:
0

Re: how to show product links on confirmation page?

Hi DrByte and Superprg,

I have made it.Thanks for your support.You people are very helpful.

Here is how i have done it.

I have used Drbyte code to achieve this.

Rather than creating the extrafunctions file myfunctions.php,I just copied the below code at the dead end(just before ?> )in the order.php.

function zen_get_products_url($product_id, $language = '') {
global $db;
if (empty($language)) $language = $_SESSION['languages_id'];
$product_query = "select products_url
from " . TABLE_PRODUCTS_DESCRIPTION . "
where products_id = '" . (int)$product_id . "'
and language_id = '" . (int)$language . "'";
$product = $db->Execute($product_query);
if ($product->fields['products_url'] == '') return false;
$url = zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product->fields['products_url']), 'NONSSL', true, false);
return '<a href="' . $url . '" target="_blank">' . MORE_INFO_TEXT . '</a>';
}


after placing this code at the end of the includes/classes/order.php, i called this function at /includes/templates/YOURTEMPLATE/templates/tpl_checkout_confirmation_default.php

around line 134 you have this: you can see this <?php echo $stock_check[$i]; ?>.

After that code, write the below code .

<?php if ($disp_url = zen_get_products_url($order->products[$i]['id']) ) echo '<br />' . $disp_url; ?>

Thats it .It worked.No header errors this Time.

Its working fine now.I have tested it.

Thanks for the work you people have done to me.I would like to work as you people to help the other newzenners.
:smartass:
Thanks
Jeethoo

3 Oct 2006, 5:24 AM
#15
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: how to show product links on confirmation page?

Glad to hear that! :yes:
Time to ponder now what was the problem in DrBytes' solution! :(

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

3 Oct 2006, 10:07 PM
#16
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: how to show product links on confirmation page?

There was no problem with my solution. The problem is how the person's editor and FTP program are uploading the file.

As for adding it to the bottom of order.php, that's fine "for now", but will be a problem when upgrading to the next version. That's why the extra_functions file was advised.

Glad it's working for you.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.