Invalid argument foreach() error in WordPress Shopping Cart Plugin

my cart iconFor the longest time I held off upgrading any of my client’s stores using WP-Shopping Cart plugin because on my test install of WP I could not get RC1 3.6.8 to work.But it really bothers me not to use the latest version of something so on one client site I did the upgrade and tested it out.I got the same exact errors I got on my test install after trying to checkout/submit and have the payment sent to PayPal.

The old invalid argument foreach() error.

Going to the forum I did not see a way to fix this probably because everyone has different causes for this error? I’m not really sure but there should be definite documentation on how to get rid of so people can have a working cart.

Error Log Messages
This error:
WordPress database error Unknown column ‘files’ in ‘field list’ for query INSERT INTO `wp_cart_contents` ( `prodid` , `purchaseid`, `price`, `pnp`, `gst`, `quantity`, `donation`, `no_shipping`, `files` ) VALUES (’18’, ’75’,’64.50′,’0′, ‘0’,’1′, ‘0’, ‘1’, ”) made by nzshpcrt_submit_checkout

Led to this error:

PHP Warning: Invalid argument supplied for foreach() in /xxx/web10/xxxx/pow.xxxl/htdocs/site/wp-content/plugins/wp-shopping-cart/merchants/paypal_multiple.php on line 82

And this all led to the cart being empty and the logs printing the price as 0.00. If the cart can’t put the order into the wp_cart_contents table it can’t process the order. Not being able to fill in the info leads to a PHP error.

Let’s look at this message again:
WordPress database error Unknown column ‘files’ in ‘field list’ for query INSERT INTO `wp_cart_contents` ( `prodid` , `purchaseid`, `price`, `pnp`, `gst`, `quantity`, `donation`, `no_shipping`, `files` ) VALUES (’18’, ’75’,’64.50′,’0′, ‘0’,’1′, ‘0’, ‘1’, ”) made by nzshpcrt_submit_checkout

Everyone of those fields has to be in the wp_cart_contents table in your WP database.If your cart works perfectly all the way up to trying to test if orders can be processed- chances are when you upgraded a field or 2 even were not created.This can happen to WP upgrades as well.It is not a failing of the cart plugin.The fact that some people have no problem upgrading anything speaks to this.

The wp_cart_contents table.
——————-Type——– –Collation — —-Attributes— — — —Null—- — Default
purchaseid—–bigint(20) ——– —– — -UNSIGNED— – — — -No—— ——0
prodid—— – bigint(20) —– —— — — -UNSIGNED– — — –No—— ——0

——————Type———- —–Collation——- —-Attributes— ——Null——-Default
price——-varchar(128)——–latin1_swedish_ci ————– ——–No———-0
pnp———varchar(128)——–latin1_swedish_ci ——– — —– —-No———-0
gst ———varchar(128)——–latin1_swedish_ci ——- ——— – — No———0
quantity– –int(10)———————————— -UNSIGNED— — No ———-0
donation– -varchar(1) ——— latin1_swedish_ci—- —— — —— No ———0
no_shipping – varchar(1)——–latin1_swedish_ci ——— —- — — – No ———- 0
files ——- —text—————-latin1_swedish_ci——— —— — — No ———-

I know it isn’t really a table but it will have to do.

Fixing It
First check your error logs. It’s good to check your error logs the very first sign of trouble. If you can see the same kind of errors that I printed here you are having the same problem I was: field files was not added to the wp_cart_contents table when I upgraded. How pesky.

1st, log into your control panel find Manage Mysql and when you are in the manage mysql area, click on Administer for your WordPress database.

When you are in, look in the left side panel for wp_cart_contents. Click on it.

Please check to see if a “files” line has been added after the no_shipping line in wp_cart_contents.
If not, don’t be scared. It is easy-peasy to add a field to a database table.If the field called files is already there your problem is being caused by something else.Check the table for missing fields you can use my ugly “graph” up above.There should be 9 fields.If anyone of these fields is missing from the table you are going to get the invalid argument foreach() error.

If the field for “files” was not added – no_shipping will be the last field in this table.It was for me.

Look for this option it’s usually underneath the bottom of the table (my host uses phpMyAdmin some other managers will be set up differently).

Add 1 field(s) At End of Table.

Leave the 1 field to be added. Leave the radio button for At End of Table selected.

Then look for the go button-Click go.

In the Field text box, type files and use all use lowercase.

In VARCHAR dropdown list, select TEXT.

Leave everything else alone and click the save button.It’s very important to save it or the field will not get added.

Test it Out!
You should now be able to add an item to the cart and checkout and send the payment to PayPal with no more errors and blank orders in the purchase logs,

if all your checkout and payment settings in the admin for the plugin are correct and there aren’t any other issues with the plugin besides the ones I have written about.

PayPal Chaps My Ass, Again

I’m trying to get something done and in order to get it done I need to have access to my PayPal account because I need to buy something that I can only buy using my PayPal account.

But because I tried to buy it PayPal froze my account. I logged into my PP account and saw that I had to go through some further account checking process because I had upgraded to a business account but hadn’t done any actual business with it,yet. So I dutifully tried to confirm my location using their confirm phone number steps.

I had my cell attached to my PP account but apparently all you crooks with cell phones are ripping folks off right and left with your cellphones and PP accounts ( I’m not devious enough to know how, not being in the possession of a crafty criminal mind). Luckily, we have a landline.
I added the landline number and was given a code.When PP called me I was instructed to enter the code into the phone and hang up.
I entered the code, hung up and clicked continue as per the instructions. But somehow it wasn’t accepted. Now the only way to confirm my location is to wait 7-9 business days for a letter from PP containing another confirmation code.

I appreciate that PP wants to protect its customers but Lord Almighty,is there not a better way?
I do not have the luxury of waiting on a letter for 9 business days.The project I am working on has a deadline.

Working like a dog.

And I smell like one too. I need a shower,bad.

I’ve been working non stop, setting up a client’s members site and a digital download store using zen cart and my brain. He wants to open the store officially today but we have been stressed because he is taking the big leap into selling downloads by himself rather than relying on another website to sell them for him. They take 40% of what he makes but everyone who wants his content knows about this middleman type of site-so the loss may be substantial or it might be none at all.We won’t know until the end of the weekend after he’s gone to his forum and told everyone about his store–which he will do tonight, I think.

Paypal has ok’d the use of their services because the store and website has no “full frontal nudity or sexual activity or underage kids” or other things that are too bad to mention. I checked with Paypal’s Appropriate Use people to make sure.

But eventually I hope to get a SSL and convince my client to spend a little $$ for a payment gateway because you’ve got to spend money to make money(I love that saying and it’s really true)

Using Paypal as an alternative to writing checks.

I have an employer who suffers from Mailitis. I am a fellow sufferer so we came up with a way for him to pay me using Paypal which does away with the whole mailing a letter thing. Only trouble is Paypal is going to get 12 dollars each time I get paid. 12 dollars? There has to be another way. And get this: Paypal took one dollar out of my account. For what reason? I don’t know. This worries me. This account-tweasing was done before I performed the Request Money request of my boss. The not funny thing is I think it was some sort of charge because I called customer service. Uncool.

I don’t think using Paypal as a means to get paid is good for anyone other than Paypal.