Post by pcp1917 » Fri Jan 31, 2014 7:49 pm

Situation:

OC 1.5.6 clean installation.
PayPal Express Checkout button: enabled (in checkout layout).
Flat Rate shipping method: disabled (sort order 1).
Weight Based Shipping: enabled (sort order 2). Tax class "Taxable Goods". Enabled for General, UK Shipping and UK VAT Zone.

In the Checkout page, click on PayPal Express Checkout button. In PayPal Gateway choose to pay with credit card (as a guest, not to pay with a PayPal account). Fill in the PayPal form and proceed (continue with the order). Now, the OC Confirm Order page appears with the "What would you like to do next?" and the order information. But...

the Weight Based Shipping is not shown!, and at the top of the page this message appears!:

"Warning: key() expects parameter 1 to be array, null given in /....../catalog/controller/payment/pp_express.php on line 620"

Does anybody know the cause?

Thanks.

Regards.

Newbie

Posts

Joined
Fri Jan 31, 2014 7:29 pm

Post by Johnathan » Fri Jan 31, 2014 11:48 pm

My guess is that the shipping isn't set before sending the data to PayPal Express, so it's looking for something that doesn't exist. I'm not sure, but you might have to have your customers apply shipping through the shipping estimator before going to PayPal Express, or get someone to modify it for you so it automatically applies a shipping cost before sending the data.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by pcp1917 » Sat Feb 01, 2014 7:09 pm

Thanks Johnathan for your reply.

I've been lokking at this deeper, and I've found that I think an "if-else" is missing. In file catalog/controller/payment/pp_express.php, the sentence:

Code: Select all

 $quote = $this->{'model_shipping_' . $result['code']}->getQuote($shipping_address);
returns an empty value. Then, the variable "$quote_data" stay empty too, but the code does not take this into account.

I think that the code should be somthing like this:

Code: Select all

					if (!empty($quote_data))  {
						$sort_order = array();

						foreach ($quote_data as $key => $value) {
							$sort_order[$key] = $value['sort_order'];
						}

						array_multisort($sort_order, SORT_ASC, $quote_data);

						$this->session->data['shipping_methods'] = $quote_data;
						$this->data['shipping_methods'] = $quote_data;
						if(!isset($this->session->data['shipping_method'])) {
							//default the shipping to the very first option.
							$key1 = key($quote_data);
							$key2 = key($quote_data[$key1]['quote']);
							$this->session->data['shipping_method'] = $quote_data[$key1]['quote'][$key2];
						}

						$this->data['code'] = $this->session->data['shipping_method']['code'];
						$this->data['action_shipping'] = $this->url->link('payment/pp_express/shipping', '', 'SSL');
					} else }
						unset($this->session->data['shipping_methods']);
						unset($this->session->data['shipping_method']);
						$this->data['error_no_shipping'] = $this->language->get('error_no_shipping');
                } else {
                    unset($this->session->data['shipping_methods']);
                    unset($this->session->data['shipping_method']);
                    $this->data['error_no_shipping'] = $this->language->get('error_no_shipping');
                }
In conclusion, adding the if-else sentence:

Code: Select all

if (!empty($quote_data))  {
    $sort_order = array();
    ......
} else {
      unset($this->session->data['shipping_methods']);
      unset($this->session->data['shipping_method']);
      $this->data['error_no_shipping'] = $this->language->get('error_no_shipping');
}
could repair the bug.

Regards.

Newbie

Posts

Joined
Fri Jan 31, 2014 7:29 pm

Post by Tom Cat » Thu Mar 06, 2014 12:18 am

I am trying to apply this fix to OC Version 1.5.6.1, but I cannot make the modification as the text /code cannot be found in the file.

Has anyone found a fix for this in Version 1.5.6.1 ?

Many thanks

New member

Posts

Joined
Thu Mar 08, 2012 4:24 am

Post by pcp1917 » Thu Mar 06, 2014 1:05 am

Tom Cat wrote:I am trying to apply this fix to OC Version 1.5.6.1, but I cannot make the modification as the text /code cannot be found in the file.

Has anyone found a fix for this in Version 1.5.6.1 ?

Many thanks
Sorry, I'm working with 1.5.6. If you fix it in 1.5.6.1 please let us know for future upgrades.

Regards.

Newbie

Posts

Joined
Fri Jan 31, 2014 7:29 pm

Post by Tom Cat » Fri Mar 07, 2014 2:22 am

So can you confirm the PayPal Express module works fine with the OC weight based shipping module in v1.5.6 ?
Also that the PayPal Express button works correctly with the weight based shipping module in v1.5.6 ?
That the fix shown above worked for v1.5.6 ?

My hosting guys say the weight based shipping module and the PayPal Express module are not compatible in version 1.5.6.1 and that if I turn off the weight based shipping module, the PayPal Express module will work correctly.

But how do I asign shipping costs? The PayPal postage calculations are not adavanced enough for my postage costs as I ship overseas?

Please confirm.

New member

Posts

Joined
Thu Mar 08, 2012 4:24 am

Post by pcp1917 » Sun Mar 09, 2014 4:12 am

In 1.5.6 the PayPal Express module works fine. I did the fix shown above by myself and worked. That's why I posted it.
About this module in 1.5.6.1, I don't know, but after reading your massege I'm shivering thinking of the next upgrade.

Regards.

Newbie

Posts

Joined
Fri Jan 31, 2014 7:29 pm

Post by James » Thu Mar 20, 2014 11:19 pm

The check if $quote_data is not empty is the best way to resolve. If no shipping quotes can be matched then it will display a message to the user.

I have attached a patched 1.5.6.1 version of the catalog/controller/payment/pp_express.php file.

I have also patched this on the 2.0 release.
https://github.com/opencart/opencart/co ... e5e4183d2f

Hope this helps.

Attachments

1.5.6.1 patched of the catalog/controller/payment/pp_express.php


User avatar
Active Member

Posts

Joined
Wed May 27, 2009 6:07 am
Location - Leeds, UK

Post by James » Thu Mar 20, 2014 11:26 pm

Actually just spotted another issue with the language string..it is missing the url link for the contact page.

$this->data['error_no_shipping'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact'));

Update file attached.

User avatar
Active Member

Posts

Joined
Wed May 27, 2009 6:07 am
Location - Leeds, UK

Post by Tom Cat » Sun Mar 30, 2014 12:26 am

Thank you James.

I now have this working in OC v1.5.6.1
The PayPal Express module works fine with my weight based shipping and so far no errors have occurred. I will let it run as my only payment option for a few days and report back.

Cheers!! :)

New member

Posts

Joined
Thu Mar 08, 2012 4:24 am

Post by Tom Cat » Wed Apr 02, 2014 11:00 pm

UPDATE: v1.5.6.1 using PayPal Express Checkout with PayPal Express Checkout button.

Ok I thought all was well, but a few errors occurred this morning with customers making multiple purchases as the payment process did not show the purchase had been made.

The OC Error Log:
Warning: Cannot modify header information - headers already sent by (output started at /home/kenwoodc/public_html/shop/catalog/language/english/payment/pp_express.php:1) in /home/kenwoodc/public_html/shop/vqmod/vqcache/vq2-system_engine_controller.php on line 28

Warning: Cannot modify header information - headers already sent by (output started at /home/kenwoodc/public_html/shop/catalog/language/english/payment/pp_express.php:1) in /home/kenwoodc/public_html/shop/vqmod/vqcache/vq2-system_engine_controller.php on line 29

Although I must add, over the weekend I installed vqmod and installed a watermark extension for my pics. Maybe this has something to do with it?

Any thoughts?

New member

Posts

Joined
Thu Mar 08, 2012 4:24 am

Post by James » Thu Apr 03, 2014 9:14 pm

Not sure what would cause that, usually a header problem is when you try to redirect and the output has already been started. There is no output on expressReturn() but there is a redirect, do you have display errors = off in the admin? If not you need to if running a live site.

If you can recreate the issue update the thread and I'll see if I can replicate :)

User avatar
Active Member

Posts

Joined
Wed May 27, 2009 6:07 am
Location - Leeds, UK

Post by Tom Cat » Fri Apr 04, 2014 12:16 am

Hi James,

I have both Display Errors: Yes and Log Errors: Yes

I run two websites, one for physical products and one for Downloads only – both upgraded to v1.5.6.1 and using PayPal Express Checkout with PayPal Express Checkout button.

Both websites are reporting the same error logs.

I had another an error occur on my downloads website in the storefront when I made a real life purchase myself from the website, paying by clicking the PayPal Express Checkout button to checkout:-

Notice: Undefined index: payment_address_id in /home4/kenwood3/public_html/catalog/controller/payment/pp_express.php on line 681

I clicked continue as the webpage was complete but had this error at the top.
The next page was blank but with the same error codes as my other website.

******************************************************************

Since writing this, my host site has come back with an answer in that they have:

I've enabled output buffering for you in a custom php.ini - can you let me know if that's helped?

I made a test purchase from my webshop without errors using the PayPal Express Checkout button so I guess this has fixed it?

BUT How can I apply this fix to my other website? I have no idea how I would create a custom php.ini and I am guessing neither having many other OC users?

Please can you help as my other website still has the errors but it is hosted with a different company.

Regards
Al.

New member

Posts

Joined
Thu Mar 08, 2012 4:24 am

Post by James » Sat Apr 05, 2014 2:39 am

I think I've narrowed down the issue. If you are logged in but still use the PayPal guest checkout it would throw the missing address ID notice (then cause the header issue too).

Try the attached file and let me know if it works ok for you. If so i'll add the fix into 1.5.6.2 release!

J

User avatar
Active Member

Posts

Joined
Wed May 27, 2009 6:07 am
Location - Leeds, UK

Post by James » Sat Apr 05, 2014 2:49 am

Also, you need to disable "disable errors" - it should only be used on a development site. Its seen as best practice to hide errors because they disclose paths. Errors will still be logged though - and this will have the same effect as what your host did as the error isn't output to the screen.

Hope this helps!

User avatar
Active Member

Posts

Joined
Wed May 27, 2009 6:07 am
Location - Leeds, UK

Post by Qphoria » Sat Apr 05, 2014 8:26 am

Tom Cat wrote: The OC Error Log:
Warning: Cannot modify header information - headers already sent by (output started at /home/kenwoodc/public_html/shop/catalog/language/english/payment/pp_express.php:1)
The error is very informative if you look carefully. This tells you there is some header data sent by this language file. This means that there are some characters or spaces or line feeds before the first <?php tag. Check that file to see what is up there.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Tom Cat » Mon Apr 07, 2014 8:42 pm

James wrote:I think I've narrowed down the issue. If you are logged in but still use the PayPal guest checkout it would throw the missing address ID notice (then cause the header issue too).

Try the attached file and let me know if it works ok for you. If so i'll add the fix into 1.5.6.2 release!

J
OK, I have added this file to both my OC websites. The Downloads only site (with no output buffering) stills reports the same header error when I check out using the button.

The physical goods site looks to be working fine with no errors reporting.

I have looked at the information Qphoria has posted. I don't fully understand, but the first code on the first line is <?php tag. There are no spaces or lines before.

Any ideas?

Correction: since posting this a customer has advised they just get a blank screen on checkout. I have disabled the PPEXCO Button module.

New member

Posts

Joined
Thu Mar 08, 2012 4:24 am

Post by James » Wed Apr 09, 2014 9:18 pm

I found the exception, PayPal does not pass back the address data if you flag the basket to contain digital items only (i.e. no shipping required)+ you use the guest checkout. It will now set the empty variables so they can be used. The downside is that no address data is collected for the order - but if it isn't supplied it can't be read :)

Try the attached.

I could not get a blank page like you mentioned, do you have any logs?

J

User avatar
Active Member

Posts

Joined
Wed May 27, 2009 6:07 am
Location - Leeds, UK

Post by Tom Cat » Wed Apr 16, 2014 3:17 am

Ok I updated both websites tonight.

My products website (with buffering) worked ok with error.

My Downloads website (without buffering) showed the errors below.
I guess I need instructions from you how to ‘enable output buffering in a custom php.ini’ for my products website.

Warning: Cannot modify header information - headers already sent by (output started at /home4/kenwood3/public_html/catalog/language/english/payment/pp_express.php:1) in /home4/kenwood3/public_html/system/engine/controller.php on line 28

Warning: Cannot modify header information - headers already sent by (output started at /home4/kenwood3/public_html/catalog/language/english/payment/pp_express.php:1) in /home4/kenwood3/public_html/system/engine/controller.php on line 29

Prevously when I had errors on the websites I disabled the PPEX Button module to stop any further errors for my customers, this would be the reason you had no blank screen. Customers can still pay with PPEX payments but without the button.

I have left the module enabled for the next 24 hrs to see if I still get errors.

New member

Posts

Joined
Thu Mar 08, 2012 4:24 am
Who is online

Users browsing this forum: No registered users and 7 guests