We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Simple Commerce Module not showing purchases

Development and Programming

communicatedesign's avatar
communicatedesign
35 posts
16 years ago
communicatedesign's avatar communicatedesign

That’s what you pass in with code for a Cart Upload. Ordinarily you would have:

item_number_1 amount_1 item_name_1 quantity_1

item_number_2 amount_2 item_name_2 quantity_2

etc etc

  • Could this be the problem?

M.

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Yes, it definitely is. With a cart, there shouldn’t be an underscore, should there? i.e. a single purchase will have ‘item_number’. If there are multiple items in your cart, they would be ‘item_number1’, ‘item_number2’, etc. At least, that’s what PayPal was doing when this module was written, and if it’s still working with the native tags, it would appear they still do.

Without either of those patterns present in the data returned by PayPal, the SCM will not process any purchases.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Just to pop in on this but I’m pretty sure that PayPal expects the underscore. This page here seems to say so? I could be reading it wrong though?

Also wouldn’t the native Simple Commerce Module tags always output item_name without a number at the end as the items are being passed one at a time to PayPal? I might be wrong on that too though? 😉

Best wishes,

Mark

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Looks like it Mark; when items are added to your cart one at a time though via the standard SCM method, PayPal builds them without the underscore, which is why the payment is still processed. PayPal sends the form fields as item_number1, item_number2, etc. in that case. When you send via the method your plugin does, however, it appears to send them back with the underscore. I love PayPal!

There’s a “Successful Purchase” code block around line 455 of mod.simple_commerce.php:

if ($this->post['num_cart_items'] != '' && $this->post['num_cart_items'] > 0 && isset($_POST['item_number1']))
{
    for($i=1; $i <= $this->post['num_cart_items']; ++$i)
    {
        if (($item_id = $IN->GBL('item_number'.$i, 'POST')) !== FALSE)
        {
            $qnty      = (isset($_POST['quantity'.$i]) && is_numeric($_POST['quantity'.$i])) ? $_POST['quantity'.$i] : 1;

You can try changing that to the following and see if it allows these purchases to come through:

if ($this->post['num_cart_items'] != '' && $this->post['num_cart_items'] > 0 && isset($_POST['item_number_1']))
{
    for($i=1; $i <= $this->post['num_cart_items']; ++$i)
    {
        if (($item_id = $IN->GBL('item_number_'.$i, 'POST')) !== FALSE)
        {
            $qnty      = (isset($_POST['quantity_'.$i]) && is_numeric($_POST['quantity_'.$i])) ? $_POST['quantity_'.$i] : 1;

Of course, I have no idea if they will be consistent and send quantity with an underscore or not (and do not have time to dive into their support area at the moment), so I’d double check your quantities are correct.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Derek,

Thanks for the code but as mentioned before the plugin doesn’t actually control any of the final output, that is entirely down to the site designer so the fields in Matt’s form above will have been dynamically coded by himself.

In that case does it simply mean that if the fields are coded in the form as item_name1 etc then it should all work. I guess that should be okay shouldn’t it?

Best wishes,

Mark

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

I don’t know, Mark; one could try that too. I was offering a coding change to the SCM that might work with the form fields with underscores. Definitely less intrusive to first try eliminating the underscores in your form fields.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Yep my thoughts too. Hopefully Matt will see these posts and give that a try. Pretty sure that should do it I would think.

Thanks again for all the help on this one.

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Matt,

Was just wondering if this got you sorted out at all? Tried e-mailing you but not sure if it got to you or not?

Hope it is all working for you now though?

Best wishes,

Mark

       
communicatedesign's avatar
communicatedesign
35 posts
16 years ago
communicatedesign's avatar communicatedesign

Hi there Thanks for your interest in this. I’ve been away over the weekend so a bit slow getting back to it.

Unfortunately, neither fix works.

Changing the mod.simple_commerce.php doesn’t result in purchases showing and removing the underscores means that either the shopping cart shows as empty when it gets to Paypal (if you remove underscores from all of the required variables) or the item_number_ variable doesn’t get passed through (if you remove the underscore from only that one).

I still think the main problem is the fact that the SCM doesn’t log ppurchases from users who aren’t logged in. I suppose I could try & ‘hack’ that by using the logmein plugin, but seeing as these fixes haven’t worked, that won’t work either…

:o/

M.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
I still think the main problem is the fact that the SCM doesn’t log ppurchases from users who aren’t logged in.

I didn’t realise you were trying this with logged-out users? If that is the case then unfortunately that would definitely be the problem as the Simple Commerce Module wouldn’t be able to know who purchased an item and when the information gets sent back to it then it wouldn’t know what to do with it.

I thought that people were going to be logged-in on your site prior to purchasing though? Is this not something that you can enforce as that should clear up your problems with this pretty quickly.

Best wishes,

Mark

       
communicatedesign's avatar
communicatedesign
35 posts
16 years ago
communicatedesign's avatar communicatedesign

I’ve been testing purchases as a logged-in user, and they still don’t show unfortunately.

I’m not (nor will the client be) in favour of enforcing registration before using the shop - that’s a sure-fire way to put some people off.

What I meant when I mentioned the problem (as I see it) with not registering purchases from non-logged-in users, I was speaking generally… I would rather have the modules register all purchases, that’s all.

M.

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Mark is correct, the solution most use is a very simple logged_in conditional. If you’re logged in, you are shown the add to cart / purchase buttons. If you are not logged in, you are shown a link to login. Simple Commerce is designed to work with the member module. To alter this, you wouldn’t have to hack the module, though, as there are hooks available that would enable your changes to work by writing an Extension.

       
communicatedesign's avatar
communicatedesign
35 posts
16 years ago
communicatedesign's avatar communicatedesign

Ok, I do understand - it’s obviously more useful if you can get people to register before making purchases (and there are other member-only functions on the site, such as the ability to contribute content) but I’m just very conscious that buying anything from the shop should be as easy as possible.

It still doesn’t show any purchases when I am logged in though.

M (o;

       
Nate Iler's avatar
Nate Iler
29 posts
16 years ago
Nate Iler's avatar Nate Iler

Maybe a little off topic, but what plugin is this thread referring to? I looked through Mark’s plugin list and didn’t see the one you guys are talking about.

Cheers

       
communicatedesign's avatar
communicatedesign
35 posts
16 years ago
communicatedesign's avatar communicatedesign

I think it’s just called ‘Shopping Cart Plugin’. It’s very good, I must say - it allows you to send the site user’s purchases to a 3rd party payment consolidator.

One thing though - you can still use Paypal, using the ‘Cart Upload’ function, but unfortunately the response back won’t register purchases with the SCM, which is a little annoying. I think I may know a way to fix it but it requires a bit of software enegineering, which is not my area of expertise.

Nothing wrong with Mark’s plugin though - I thoroughly recommend that. Very easy to install and set up with your templates.

       
1 2 3

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.