Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PayPal Express how to ignore cheapest shipping - in store pickup


greasemonkey

Recommended Posts

<p>Hi All, I'm in the process on upgrading form 2.3.3.4 to 2.3.4 and thought I should really get in the game and upgrade to PayPay Express - specifically so I can use the Login With PayPal module. I've always used the older IPN modules or, since I upgraded last year from 2.2 to 2.3.3.x, the PP Standard module. Anyway, the issue I have is this; I use a simple flat rate shipping module (in addition to a Postal Service and FedEx module) at $0.00, with a zone for local customers to choose. PayPal Express is default choosing this "in store" $0.00 module as the cheapest option when using the "checkout with PayPal" button from the shopping_cart page... not a huge deal... except there is no dropdown to select other shipping methods - as there is when a customer is logged in and uses PP Express from the checkout_payment page. I added previously to include/classes/shipping.php the following code to choose a module greater than $0.00 as default in checkout_shipping

            //if ($rates[$i]['cost'] < $cheapest['cost']) {   //edit to remove $0.00 from cheapest shipping... sb//   if ($rates[$i]['cost'] < $cheapest['cost'] && $rates[$i]['cost'] > 0) {
I've been trying to add something similar in ext/modules/payment/paypal/express.php but my php skills are lack luster at best... Around here;
            if (is_null($cheapest_rate) || ($shipping_rate < $cheapest_rate)) {              $cheapest_rate = $shipping_rate;              $cheapest_counter = $counter;            }
I'm using the latest PP Express addon that came included with 2.3.4 upgrade package. Any idea's would be greatly appreciated.</p>
Link to comment
Share on other sites

I had the same problem with MZMT shipping and thanks to Harald I have it sorted:

 

open up ext/modules/payment/paypal/express.php and change line 243 to:
 

if ( ($quote['id'] != 'collection_collection') && (is_null($cheapest_rate) || ($shipping_rate < $cheapest_rate)) ) {

You will need to change Collection_collection to the name of your module

 

Also try logging into paypal when you checkout - it should then provide a dropdown box to select shipping.

 

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

try:

if ( ($quote['id'] != 'flat_flat') && (is_null($cheapest_rate) || ($shipping_rate < $cheapest_rate)) ) {

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

@@greasemonkey it is the standard Flat Rate Shipping module and not the Zones shipping module?

Edited by Mort-lemur

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

in the includes/modules/shipping/module you are using.php

 

is line 20 this:

      $this->code = 'flat';

and around line 51 this:

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                     'cost' => MODULE_SHIPPING_FLAT_COST)));

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

@@Mort-lemur yes my lines are the same.

 

 

in the includes/modules/shipping/module you are using.php

 

is line 20 this:

      $this->code = 'flat';

and around line 51 this:

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                     'cost' => MODULE_SHIPPING_FLAT_COST)));
Link to comment
Share on other sites

Just a quick update. I deactivated the flat rate (in store $0.00) module - to see how it would/should work properly and the result is NO shipping is being passed to PP when checking out as a guest from the shopping cart page.

 

However I was redirected to checkout_confirmation and the cheapest shipping was added.

 

A customer account is also created.

 

I re-activated the flat rate module and retested both with and without

if ( ($quote['id'] != 'flat_flat') && (is_null($cheapest_rate) || ($shipping_rate < $cheapest_rate)) ) {

And the "in store" $0.00 shipping was passed to the paypal confirmation screen AND when I hit Pay Now the checkout was completed without redirecting to checkout_confirmation and with $0.00 in shipping.

 

The only other things I can add are;

 

In my PP profile I have checked the box for; Click here to allow transaction-based shipping values to override the profile shipping settings listed above (if profile settings are enabled).

 

I have a SSL certificate and the SSL is enable in PP Express.

 

I doing this with live credentials and live customer (not sandbox).

 

I added a debug email line to see what is returned and received

$HTTP_GET_VARS:

Array
(
    [osC_Action] => retrieve
    [token] => EC-6BX11226R8812711S
    [PayerID] => YCDKKTYFXJZQA
)

Any other thoughts would be greatly appreciated...

Link to comment
Share on other sites

How about trying this:

 

Rather than having the collection option as a zone in the flat rate shipping module install the collect in person shipping module, then try the code that Harald gave me to get it working for me. ie:

if ( ($quote['id'] != 'collection_collection') && (is_null($cheapest_rate) || ($shipping_rate < $cheapest_rate)) ) {

then you font have to have $0.00 set as a shipping rate in flat rate and the code above will make PP ignore the Collection module.

 

Worth a try....

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

@@Mort-lemur tried, but did not work. I also tried activating the zones module and using the same code with zones_zones and this also did not work.

 

Just reading through the latest release PayPal Express documents here http://library.oscommerce.com/Package&en&paypal&oscom23&express_checkout It would seem there is something wrong. The docs clearly state a drop down menu should be available, with the "Instant Update" feature turned on (it is) when the customer logs into their paypal account.

 

 

As soon as the customer has logged in at PayPal or has provided their shipping address during the Express Checkout flow, PayPal contacts your online store to retrieve a list of applicable shipping rates and taxes for the shipping destination. The customer is able to choose their preferred shipping rate which is passed back to the store to use for the order.

 

The ONLY way I'm getting the drop down is if the customer is logged into the store.

 

The communication for the shipping rate, between my store and PP, is not correct otherwise. Interestingly, the tax calculation seems to be working using the Guest Checkout.

 

I have tested the API server connection and everything is fine there....

 

I have read in other thread issues with SSL certs not being properly recognize... Does anyone know how to test is?

Link to comment
Share on other sites

Looks like you need to catch @@harald in the chat room...

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

Ok, all. I have testing again with Harald's help in sandbox and PP Express works as it should. However in live does not work. Sandbox does not use SSL - Live does not. It would seem, at this point, the cause is something to do with my SSL cert and PP. I will be calling now.

 

Some reference here

 

http://stackoverflow.com/questions/18529619/paypal-instant-update-callbackurl-not-being-called-in-live-setup

Link to comment
Share on other sites

Hi All, ok I believe I have diagnosed the issue... However... I don't know how to fix it - and worry it may not be possible to fix.

 

Reading through all the info on the PayPal forums at stackoverflow (specifically this post; http://stackoverflow.com/questions/15353067/paypal-instant-update-api-not-working-on-https) it would seem this issue is typically caused by 1 of 2 things;

 

1) an SSL that is not recognised by PayPal

 

or

 

2) a callback timeout that takes longer than 6 seconds

 

I have an up to date, name brand SSL so I was sure it was not the issue. To prove this I de-activated all my shipping modules except the flat rate (in store $0.00) module. Then installed a basic zone module and retested PP Express with live credentials and VOILA. The shipping selection in PP via instant update now works. So, in conclusion, the issue must be caused by my 2 main external API shipping modules (Canada Post & fedex Webservices) taking longer than the max allowed callback for PayPal Express (set at 6 in ext/modules/payment/paypal/express.php on line 799).

 

As soon as 1 of these 2 modules (either one) is activated the shipping selection in PP via instant update no longer works.

 

@Harald Ponce de Leon there is talk on stackoverflow of an artificial "sleep" to extend the timeout - would you be able to provide any advice on how to implement something of this nature - at least for testing?

 

My second theory, if the above is not correct is; PayPal is rejecting the callback altogether because it contains external API shipping quotes... Not sure if this is possible as the info would be coming through my site first and delivered to PP on my SSL?

Link to comment
Share on other sites

I don't know how useful this will be, however I just hacked in a second connection test to test the instant update url. The problem is, this tests the connection from your webserver to your webserver and does not reveal how long it takes for PayPal to make the same request.

 

paypal_express.php

 

Copy the attached file to includes/modules/payment/ and overwrite the v3.1 file.

 

This update is a hardcore hack not ready for the public. The following lines need to be edited:

 

Line 806: Enter a valid product ID for a shippable product without attributes

Lines 808-812: Enter a valid address to ship to

 

A second Test API Server Connection link is added to the module configuration page. Use this to see how long it takes your server to calculate the Instant Update result. Ignore whatever text is displayed on error as it's not relevant to Instant Update. It should show "Success!" and the time the request took.

 

Again, its a hardcore hack just to quickly test Instant Update. This definitely needs to be worked on if it is to be added to a module update.

:heart:, osCommerce

Link to comment
Share on other sites

@@Harald Ponce de Leon ok test is done and the result is just over 2 seconds on multiple attempts in IE 10.

 

I tested with 1 external shipping module and 2. The results we approximately the same on each test.

 

The highest I saw was with a FF for TOR at 5.5 seconds;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...