Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Is it possible to include shopping car contents in html page?


dowser

Recommended Posts

What would it take to include shopping cart contents on top of an html page? I'm trying to create templates for the rest of my website converted into OSC and having that would look nice and be very useful from shopper's perspective.

 

Any ideas?

Link to comment
Share on other sites

Very possible.

 

1. Get your html pages to understand php addtype <-- search in google for that

2. then include application_top.php

3. show the cart count and value.

 

 

Yes, they are php ready, will give it a try, thank you!

 

If it works fine - it could be a part of a contribution, there are a lot of websites that were converted to OSC.

Link to comment
Share on other sites

Very possible.

 

1. Get your html pages to understand php addtype <-- search in google for that

2. then include application_top.php

3. show the cart count and value.

 

OK, I've tried to include the applicatio_top.php:

 

<?php include ('/store/includes/application_top.php'); ?>

 

but got the following error:

 

Warning: include(/store/includes/application_top.php) [function.include]: failed to open stream: No such file or directory in /home/xxxx/public_html/index-main.html on line 30

 

Warning: include() [function.include]: Failed opening '/store/includes/application_top.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/divining/public_html/index-main.html on line 30

 

This is the line 30 of my code:

 

<td><?php include ('/store/includes/application_top.php'); ?></td>

 

Is there anything else I need to do? Sorry, I'm not well versed in php... I probably skipped your point 3, but have no idea how to do it.

Link to comment
Share on other sites

Very possible.

 

1. Get your html pages to understand php addtype <-- search in google for that

2. then include application_top.php

3. show the cart count and value.

 

I've tried removing the back slash (relative path), but now I got:

 

Warning: require(includes/configure.php) [function.require]: failed to open stream: No such file or directory in /home/divining/public_html/store/includes/application_top.php on line 28

 

Warning: require(includes/configure.php) [function.require]: failed to open stream: No such file or directory in /home/divining/public_html/store/includes/application_top.php on line 28

 

Fatal error: require() [function.require]: Failed opening required 'includes/configure.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/divining/public_html/store/includes/application_top.php on line 28

 

How to include the required configure.php without security issues?

 

Link to comment
Share on other sites

This might work:

 

  chdir( 'store');
 require('includes/application_top.php');

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 >

Link to comment
Share on other sites

I've tried it, but now there is an issue with session cookies...

If the cookie path in the config file is:

 

  define('HTTP_COOKIE_PATH', '/store/');

Changing it to:

 

  define('HTTP_COOKIE_PATH', '/');

Might fix the problem.

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 >

Link to comment
Share on other sites

If the cookie path in the config file is:

 

 define('HTTP_COOKIE_PATH', '/store/');

Changing it to:

 

 define('HTTP_COOKIE_PATH', '/');

Might fix the problem.

 

It fix the errors, but still doesn't display anything...

Link to comment
Share on other sites

In your server PHP configuration (usually php.ini file) try adding your store's base path to the "include_path" setting, so you get

include_path='.:/home/divining/public_html/store:/usr/lib/php:/usr/local/lib/php'

That way PHP will look for /home/divining/public_html/store/includes/configure.php, as well as ./includes/configure.php. /usr/lib/php/includes/configure.php and /usr/local/includes/configure.php shouldn't be checked, as the file will already be found.

Link to comment
Share on other sites

In your server PHP configuration (usually php.ini file) try adding your store's base path to the "include_path" setting, so you get

include_path='.:/home/divining/public_html/store:/usr/lib/php:/usr/local/lib/php'

That way PHP will look for /home/divining/public_html/store/includes/configure.php, as well as ./includes/configure.php. /usr/lib/php/includes/configure.php and /usr/local/includes/configure.php shouldn't be checked, as the file will already be found.

 

I don't have access to the server's root, is there any other way of accomplishing that?

Link to comment
Share on other sites

Yes, it worked fine - however, please note that I am testing this on http://localhost not a live server...which could possibly make a difference.

 

<?php
chdir('oscommerce');
require('includes/application_top.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
 <title>Test</title>
</head>
<body>
<h1>Test</h1>

<p>You have <?php echo $cart->count_contents(); ?> <?php echo $cart->count_contents() == "1" ? "item" : "items"; ?> in your cart.</p>

</body>
</html>

 

and the .htaccess

 

AddType application/x-httpd-php .php .htm .html

Link to comment
Share on other sites

I don't have access to the server's root, is there any other way of accomplishing that?

You don't do this in the server root -- you do it in your site root (/php.ini). Talk with your hosting service to see how to set up a php.ini file, where to put it, and whether you need to change any other files in the process (such as .htaccess). What you want to accomplish is expanding the PHP "include_path" setting to include your store's root.

Link to comment
Share on other sites

Yes, it worked fine - however, please note that I am testing this on http://localhost not a live server...which could possibly make a difference.

 

<?php
chdir('oscommerce');
require('includes/application_top.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>

<p>You have <?php echo $cart->count_contents(); ?> <?php echo $cart->count_contents() == "1" ? "item" : "items"; ?> in your cart.</p>

</body>
</html>

 

and the .htaccess

 

AddType application/x-httpd-php .php .htm .html

 

It works fine - till I add something to the cart. Then I get:

 

Fatal error: Call to a member function add_current_page() on a non-object in /home/divining/public_html/store/includes/application_top.php on line 321

 

Looks like it's tougher than I thought...

Link to comment
Share on other sites

You don't do this in the server root -- you do it in your site root (/php.ini). Talk with your hosting service to see how to set up a php.ini file, where to put it, and whether you need to change any other files in the process (such as .htaccess). What you want to accomplish is expanding the PHP "include_path" setting to include your store's root.

 

OK, I better talk to my host, he is pretty good with things like that

Link to comment
Share on other sites

OK, I better talk to my host, he is pretty good with things like that

About that error....

 

Follow the links in my posts here: Click Me

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 >

Link to comment
Share on other sites

About that error....

 

Follow the links in my posts here: Click Me

 

Well - now I'm getting:

 

Fatal error: Call to a member function count_contents() on a non-object in /home/xxxx/public_html/testingcart.htm on line 15

 

I'm ready to give up and just use a link to the shopping cart...

Link to comment
Share on other sites

Yes, it worked fine - however, please note that I am testing this on http://localhost not a live server...which could possibly make a difference.

 

<?php
chdir('oscommerce');
require('includes/application_top.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>

<p>You have <?php echo $cart->count_contents(); ?> <?php echo $cart->count_contents() == "1" ? "item" : "items"; ?> in your cart.</p>

</body>
</html>

 

and the .htaccess

 

AddType application/x-httpd-php .php .htm .html

 

I finally got it working without errors, but it's not updating, the cart remains at zero even after adding products. crying.gif

Link to comment
Share on other sites

I finally got it working without errors, but it's not updating, the cart remains at zero even after adding products. crying.gif

If you aren't using the osC function tep_href_link INSIDE the store to link to the page OUTSIDE the store you may be losing the session ID and thereby dumping the cart contents.

 

There is a thread about that here

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 >

Link to comment
Share on other sites

If you aren't using the osC function tep_href_link INSIDE the store to link to the page OUTSIDE the store you may be losing the session ID and thereby dumping the cart contents.

 

There is a thread about that here

 

Sorry, that's over my head! I better gracefully withdraw thanking everybody for their input, otherwise I might get lost :blush:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...