Etomite Community Forums: [Snippet] etoBasket for paypal - Etomite Community Forums

Jump to content

Read Me

This forum is posted in automatically when a snippet is added to the library, or updated. Please use the snippet topic to discuss that snippet.
  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[Snippet] etoBasket for paypal

#1 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,076
  • Joined: 10-August 06
  • Gender:Not Telling

Posted 16 September 2007 - 12:02 PM

File Name: etoBasket for paypal
File Submitter: Cris D.
File Submitted: 16 Sep 2007
File Updated: 17 Nov 2007
File Category: 3rd Party Integration

SNIPPET: etoBasketV1.1
DATE: 16/9/07
Updated:27/10/07
BY: Cris D for Etomite CMS

USE: Creates multiple item shopping page that allows users to purchase items through paypal

LIMITATIONS: Due to the complex and changing field of on-line shopping, this snippet is designed as a base to start from and must be cusomised for individual use. Individual circumstances change dramatically, therefore only assistance with the snippet code logic will be offered in the etomite forums.

###### For paypal assistance, please see paypal.com. ######

INSTALLATION INSTRUCTIONS:
  • Copy and paste this code into your snippet library.
  • Change the items requiring configuration. Save it as etoBasket.
  • Call the snippet in a page [!etoBasket!] and start entering your items for sale.
  • This snippet assumes that you have a current paypal account to receive payments (d'oh).


SECURITY and LOGGING IN: If you will need to have the snippet authenticate_visitor on your site to log in and enter data or place a snippet call ?permission=1 to temporarily override the authentication temporarily (doing this is a security risk and is not the recommended method of use!).

CREDITS: robsta for the initial paypal snippet, Ralph and Dean for Etomite!

See a simple 3 item sample (not an active shop) page here (obviously you can't see the managers page so here's a screenshot.

THE DETAILS:
You can set the following item details in the manager:
Title,
Description,
Price,
picture folder/,
picture filename,
page to show on (for categories),
active? (to temporarily hide).

The following paypal fields are configurable:
your email?
button image?
button alt=""?
default: how many to add?
_CMD:_cart
Paypal page style?
Return page on success of payment?
note? no note? (allows customers to leave a message or not).
Currency?
Location code?
currency Icon="$" ?

Other tweaks available...

You can also control how it presents if you (optionally) copy and paste the "InternalTemplate" and save it as a new chunk, set the $paypalChunk="yourChunkHere"; and your template will be used to display the data.

Additionally, I have built in a delete confirmation message that does NOT use java so IE with pop-ups blocked still works.

Additional data can easily be added at line 302 where the $PAYPAL_INFO array is built inside the snippet before merging with the template. This allows users to add any other variables they like to the output.

You can also use the div.pp_odd and div.pp_even classes to display alternating records differently if desired.

CHANGELOG:
Updated 27/10/07 Ver 1.1
  • Changed the form action from '_blank' to 'paypal' to stop numerous carts from opening up.
  • Added a "view cart" link above the first item and below the last item on the page. This link can also be configured to use a button image instead of text.

Updated 2007/11/17
Fixed some minor validation issues. This snippet now outputs valid code.

Click here to download this file

#2 User is offline   Bjarne 

  • Etomite Forum Fan
  • Pip
  • Group: Member
  • Posts: 94
  • Joined: 28-December 04

Posted 18 September 2007 - 12:41 PM

This is something I really have waited for. Struggling with Zen cart for small scale web shops is not my favourite hobby. Right now I am planning to set up a small book store for a foundation wich publish a few books every year. Zen Cart is totally overkill for this, so a snippet like this is more than welcome. But, and this is an important but, in your demo you go directly to Paypal when clicking an item, and frankly, you don't need much of a snippet to do so ...

A great deal of the customers want to buy more than one title, so I need some sort of shopping basket that allows you to selct more than one item before you go top PayPal. Is this a feature here? If not, will it be in near future?

#3 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,076
  • Joined: 10-August 06
  • Gender:Not Telling

Posted 18 September 2007 - 12:51 PM

The way it is set up is that if you click the add to basket button, it adds that item to the paypal basket in a new window. You can continue adding items until you are ready to head to the checkout. The paypal cart can be modified with your css [edit: not your sites css, paypal has the ability to style your cart] to make it look like your site.

[EDIT] The main advantage this snippet has over the original by robsta is that you used to have to manually add (to the snippet call) the name & price to each item listed. very time-consuming. And you had to edit the page to add and delete items. This snippet was written to speed up that process heaps.[/EDIT].

This post has been edited by Cris D.: 18 September 2007 - 08:41 PM


#4 User is offline   DeepWoods 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 8
  • Joined: 12-October 07
  • Location:Paragould, Arkansas
  • Interests:Network Architecture, programming, web development, hunting, fishing, golf, and home CNC.

Posted 23 October 2007 - 07:11 PM

Any ideas what could be causing this error?

Etomite encountered the following error while attempting to parse the requested resource:
« Execution of a query to the database failed »
SQL: SHOW TABLE STATUS LIKE 'etomite_etoBasket'


Running on:
CentOS release 4.4
0.6.1 Final (PL:4) (Prelude)
mysql Ver 14.12 Distrib 5.0.27, for redhat-linux-gnu (i686) using readline 5.0

From the shell I got:
mysql> show table status like 'etomite_etoBasket';
Empty set (0.00 sec)

So I manually created the table with this query and tried again and get the same error still.
CREATE TABLE etomite_etoBasket (id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, item VARCHAR(100) NULL, 
   description VARCHAR(500) NULL, price VARCHAR(10) NULL, pic_folder VARCHAR(50) NULL, 
   filename VARCHAR(20) NULL, onPage INT( 10 ) NULL, active ENUM('1','0') NOT NULL DEFAULT '1') 
   ENGINE = myisam;


Regards,
Rob

#5 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,076
  • Joined: 10-August 06
  • Gender:Not Telling

Posted 23 October 2007 - 07:33 PM

I'm not familiar with that version of MySQL.
Are you saying that you tried to install the snippet and it would not install? Then when you installed it manually the table is there but the snippet will not connect to it?

From best guess, it looks to be coming from the extTableExists API check.
Try changing the lines adding the following parameters manually...
$host = 	$GLOBALS['database_server']; 
$user = 	$GLOBALS['database_user']; 
$pass = 	$GLOBALS['database_password']; 
$dbase =	$GLOBALS['dbase'];

ie change to...
$user= "put_your_username_here"; etc...
Let me know how you go.

#6 User is offline   DeepWoods 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 8
  • Joined: 12-October 07
  • Location:Paragould, Arkansas
  • Interests:Network Architecture, programming, web development, hunting, fishing, golf, and home CNC.

Posted 24 October 2007 - 01:04 AM

View PostCris D., on Oct 23 2007, 03:33 PM, said:

I'm not familiar with that version of MySQL.
Are you saying that you tried to install the snippet and it would not install? Then when you installed it manually the table is there but the snippet will not connect to it?

Correct on both accounts.

View PostCris D., on Oct 23 2007, 03:33 PM, said:

From best guess, it looks to be coming from the extTableExists API check.
Try changing the lines adding the following parameters manually...
$host =	 $GLOBALS['database_server']; 
	 $user =	 $GLOBALS['database_user']; 
	 $pass =	 $GLOBALS['database_password']; 
	 $dbase =	$GLOBALS['dbase'];

ie change to...
$user= "put_your_username_here"; etc...
Let me know how you go.

Good news, bad news. Good news is that hard coding the db variables gets rid of the error. Bad news is that now nothing is returned at all from the snippet. Thinking it might be an issue with MySQL 5, I tried installing the snippet on a virtual server running CentOS 4.5, MySQL 4.1.20, and eto 6.1.4 and have the same problem. Does register_globals need to be enabled in php.ini? I have it disabled and am running php 4.3.9 on the virtual server. Maybe I'm just not understanding how it's supposed to be called in the page or am missing something basic? I'm just creating the snippet, making a new page, and then adding [!etoBasket?permission=1!] to the new page. Am I missing anything? Any help is greatly appreciated.

Regards,
Rob

#7 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,076
  • Joined: 10-August 06
  • Gender:Not Telling

Posted 24 October 2007 - 06:12 AM

It all looks right, did you change the following GLOBALS line to hard code it too?

$etoPrefix=$GLOBALS['table_prefix'];//automatically set to the prefix of the etomite installation.


The only other thing I would suggest is that I have not tested this on the OS you are describing and am not familiar with its limitations, therefore I can not say if it is part of the problem.

There may be nothing returned from the snippet because there is a permission problem and therefore the data entry forms are not being returned. Because you have not entered anything yet, no results are returned. To see if it is a data display problem you could try putting an entry in the table with phpMyAdmin to see if it displays).
Or try putting the line:
$output.="Hi There"; //on the second-last line of the snippet.

If it is a permissions problem, then "Hi There" should still show up. If this does not show, then I assume you would have problems with ALL etomite snippets.

If "Hi There" does show, it could be the virtual environment. I have had quirky behavior with localhosts in the past, the configuration can definitely make an impact on how logins and forms behave. Ther versions of MySQL this has been tested on include: 4.1.22, and my localhost:5.0.33

[EDIT] if you want me to have a poke around your install to see what the problem is, I'm happy to... I can't guarantee I can fix it though!

This post has been edited by Cris D.: 24 October 2007 - 12:21 PM


#8 User is offline   DeepWoods 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 8
  • Joined: 12-October 07
  • Location:Paragould, Arkansas
  • Interests:Network Architecture, programming, web development, hunting, fishing, golf, and home CNC.

Posted 24 October 2007 - 02:49 PM

View PostCris D., on Oct 24 2007, 02:12 AM, said:

It all looks right, did you change the following GLOBALS line to hard code it too?

$etoPrefix=$GLOBALS['table_prefix'];//automatically set to the prefix of the etomite installation.

No, just the host, user, passwd, and db. After reading this though, I tried that with the same results.

View PostCris D., on Oct 24 2007, 02:12 AM, said:

The only other thing I would suggest is that I have not tested this on the OS you are describing and am not familiar with its limitations, therefore I can not say if it is part of the problem.

CentOS is derived from the Redhat Enterprise sources. Basically, they just remove the RH trademarks and logos and repackage it.

View PostCris D., on Oct 24 2007, 02:12 AM, said:

There may be nothing returned from the snippet because there is a permission problem and therefore the data entry forms are not being returned. Because you have not entered anything yet, no results are returned. To see if it is a data display problem you could try putting an entry in the table with phpMyAdmin to see if it displays).
Or try putting the line:
$output.="Hi There"; //on the second-last line of the snippet.

If it is a permissions problem, then "Hi There" should still show up. If this does not show, then I assume you would have problems with ALL etomite snippets.

If "Hi There" does show, it could be the virtual environment. I have had quirky behavior with localhosts in the past, the configuration can definitely make an impact on how logins and forms behave. Ther versions of MySQL this has been tested on include: 4.1.22, and my localhost:5.0.33

Here's what I've done to this point:
mysql> insert into etomite_etobasket (item, description, price, pic_folder, filename, onPage, active) values ('test', 'test item', '10.00', 'assets/images/', 'logo.jpg', '55', '1');
 Query OK, 1 row affected (0.00 sec)
 
 mysql> select * from etomite_etobasket;
 +----+------+-------------+-------+----------------+-----------+--------+--------+
 | id | item | description | price | pic_folder	 | filename  | onPage | active |
 +----+------+-------------+-------+----------------+-----------+--------+--------+
 |  1 | test | test item   | 10.00 | assets/images/ | logo.jpg |	 55 | 1	  |
 +----+------+-------------+-------+----------------+-----------+--------+--------+
 1 row in set (0.00 sec)

That actually returns an item to the page here: http://170.211.125.79/eto/index.php?id=55 along with my version of your "Hi There" addition to the snippet output. Still, with [!etoBasket?permission=1!], shouldn't there be some options available on the page to edit/add items? Or is the authenticate_visitors snippet necessary for that to work? I'd planned on adding it once I got the basic basket to work first.

View PostCris D., on Oct 24 2007, 02:12 AM, said:

[EDIT] if you want me to have a poke around your install to see what the problem is, I'm happy to... I can't guarantee I can fix it though!

I just appreciate your trying to help! Thanks!

Rob

#9 User is offline   Ralph 

  • Etomite Administrator
  • Group: Admin
  • Posts: 6,418
  • Joined: 01-July 04
  • Gender:Male
  • Location:Jamestown, NY USA
  • Interests:Computers, Camping, Hiking, Aviation

Posted 24 October 2007 - 04:55 PM

View PostDeepWoods, on Oct 23 2007, 04:11 PM, said:

Any ideas what could be causing this error?

Etomite encountered the following error while attempting to parse the requested resource:
« Execution of a query to the database failed »
SQL: SHOW TABLE STATUS LIKE 'etomite_etoBasket'

This is a common error with cross-platform releases of MySQL and this issue has been discussed in other forum threads on this site... It could be a configuration setting, for security reasons, or some other obscure rationale that causes some commands to not work... If you have ever browsed around in Plesk or cPanel you would find that you can restrict some of the MySQL commands and this might be the case in your situation... At any rate, it isn't a bug within the Etomite code base itself but, rather, a server configuration issue...

#10 User is offline   DeepWoods 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 8
  • Joined: 12-October 07
  • Location:Paragould, Arkansas
  • Interests:Network Architecture, programming, web development, hunting, fishing, golf, and home CNC.

Posted 24 October 2007 - 06:32 PM

View PostRalph, on Oct 24 2007, 12:55 PM, said:

This is a common error with cross-platform releases of MySQL and this issue has been discussed in other forum threads on this site... It could be a configuration setting, for security reasons, or some other obscure rationale that causes some commands to not work... If you have ever browsed around in Plesk or cPanel you would find that you can restrict some of the MySQL commands and this might be the case in your situation... At any rate, it isn't a bug within the Etomite code base itself but, rather, a server configuration issue...

Any ideas specifically which config setting(s) needs changed or where I might find information on it? I don't have any control panels installed on the servers(both are development machines) in question and default installations of mysql with basic security.
What's odd is that executing the command from the shell works fine:
mysql> SHOW TABLE STATUS LIKE 'etomite_etobasket';
   +------------------- +-------- +--------- +------------ +------ +---------------- +------------- +----------------- +-------------- +----------- +---------------- +--------------------- +--------------------- +------------ +------------------- +---------- +---------------- +---------+
   | Name			  | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time		 | Update_time		 | Check_time | Collation		 | Checksum | Create_options | Comment |
   +------------------- +-------- +--------- +------------ +------ +---------------- +------------- +----------------- +-------------- +----------- +---------------- +--------------------- +--------------------- +------------ +------------------- +---------- +---------------- +---------+
   | etomite_etobasket | MyISAM |	   9 | Dynamic	|	1 |			 64 |		  64 |	  4294967295 |		 2048 |		 0 |			  2 | 2007-10-23 20:00:47 | 2007-10-24 09:24:11 | NULL	   | latin1_swedish_ci |	 NULL |				|		 |
   +------------------- +-------- +--------- +------------ +------ +---------------- +------------- +----------------- +-------------- +----------- +---------------- +--------------------- +--------------------- +------------ +------------------- +---------- +---------------- +---------+
   1 row in set (0.00 sec)

So does that mean it's a php, apache, or mysql issue?
I manage the servers in question(and then some) so changing configs isn't an issue if I just knew what to modify??? Thanks!

Rob

#11 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,076
  • Joined: 10-August 06
  • Gender:Not Telling

Posted 24 October 2007 - 08:41 PM

I don't know much about server configuration so poking around your insallation would probably be a waste of time.
However, now that your snippet is working, it is almost definately a permissions issue. Install "Authenticate_visitor", remove the ?permission=1 and see if your entry forms are returned on the etoPaypal when logged in.

#12 User is offline   DeepWoods 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 8
  • Joined: 12-October 07
  • Location:Paragould, Arkansas
  • Interests:Network Architecture, programming, web development, hunting, fishing, golf, and home CNC.

Posted 25 October 2007 - 12:09 AM

View PostCris D., on Oct 24 2007, 04:41 PM, said:

I don't know much about server configuration so poking around your insallation would probably be a waste of time.
However, now that your snippet is working, it is almost definately a permissions issue. Install "Authenticate_visitor", remove the ?permission=1 and see if your entry forms are returned on the etoPaypal when logged in.

You were correct Cris. Adding the authentication worked. The magic combination of hard coding the DB variables(wondering if register_globals being disabled in php is the problem there?) and adding the authentication snippet has everything working as it should.

Thanks for the help!
Rob

#13 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,076
  • Joined: 10-August 06
  • Gender:Not Telling

Posted 25 October 2007 - 09:49 AM

I did some reading up on the use of and access of $GLOBALS, and basically, it is PHP's preferred method of setting global variables.

Quote

Using the available PHP Reserved Predefined Variables, like the superglobal arrays, is preferred.

http://au3.php.net/variables.predefined
This is in light of the change to the default settings for register_globals set to =OFF from ver 4.2.0 onwards. $GLOBALS has been implemented as a safer method of setting global variables and still works with register_globals off. (I can confirm this on one other site).
Why you (and cathode) have problems accessing this variable is odd. However PHP also notes that the results of global variables and their ability to be called inside nested functions and on various servers still varies widely.
Perhaps the use of this superglobal variable is not recommended for further snippet development because of these variances in performance but I honestly can't see why it would not work. I found it to use in Etomite's code base so I'm assuming it is required for Etomite to work and therefore a fairly reliable variable source.

Ifyou wants to rule this out as a problem with any of my other snippets using $GLOBALS variables, give EtoInfo a go, it shows you exactly what variables are available for use on any given Etomite installation.
eg:

Quote

GLOBAL VARIABLES: available in snippets with $GLOBALS['name']
Global Variable Name Global Value
GLOBAL['database_server']: my.database.host
GLOBAL['dbase']: `dbmydatabasename`
GLOBAL['database_user']: myusername
GLOBAL['database_prefix']: etomite_
GLOBAL['database_password']: mypassword
GLOBAL['absolute_base_path']: /base/path/to/siteroot/www/
GLOBAL['relative_base_path']: /
GLOBAL['www_base_path']: http://www.mysite.com/


#14 User is offline   cathode 

  • Etomite Staff
  • Group: Staff
  • Posts: 654
  • Joined: 21-November 05
  • Location:Indiana, U.S.

Posted 25 October 2007 - 01:46 PM

Chris,
I like this snippet - It is a very easy way for an Etomite user to setup a paypal store. One suggestion, I wonder if it would be possible to generate the "Proceed to checkout" button to display after/before the list of products.

#15 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,076
  • Joined: 10-August 06
  • Gender:Not Telling

Posted 25 October 2007 - 08:23 PM

I'll have a into it over the weekend.

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users