wp-e-commerce / WP-e-Commerce

WP eCommerce - The most popular independent eCommerce platform for WordPress
https://wpecommerce.org
GNU General Public License v2.0
213 stars 216 forks source link

Shipping fees not recalculating #1684

Open npdemers opened 9 years ago

npdemers commented 9 years ago

I recently upgraded my site from WP e-commerce 3.8.12.1 to 38.14.4, and I ran into a couple problems. One of those problems went away when I tried 3.9, but the other persists:

I'm using the WP E-Commerce Weight & Destination Shipping Modules to get a shipping fee based on the shipping continent. In 3.8.12.1 on the checkout page, when I clicked on the "Shipping Address same as Billing Address?" checkbox, the shipping fees were recalculated immediately. This does not happen in 3.8.14.4 or 3.9. I made no changes to the configuration after upgrading.

I'm running WP 4.0, with a custom theme.

JustinSainton commented 9 years ago

Assigning to @leewillis77 to see if he can take a peek. @npdemers - do you have a live site where we can see the bug in action?

npdemers commented 9 years ago

Yes: http://dreamfilm.staging.wpengine.com/store

Thanks!

JustinSainton commented 9 years ago

Hi @npdemers

I am unable to get any shipping quotes at all...is that expected?

http://cl.ly/image/3Z0A3P3v1P23

leewillis77 commented 9 years ago

On my local install, if I choose France as the shipping address, retrieve quotes, then fill in my shipping country as the UK, then tick the "shipping same as billing" option, then the country in the shipping calculator is set to UK, and I get the "Please click the Calculate button to refresh your shipping quotes, as your shipping information has been modified." message. Hitting calculate brings through the correct rate.

So - in short - I can't reproduce this.

pavelevap commented 9 years ago

leewillis77: Same problem. Clicking "Shipping same as billing" and warning appears. I am using only one (same) country for selling and shipping.

leewillis77 commented 9 years ago

OK - so, there's definitely something wonky somewhere. On a fresh install of 3.9 the following POST data is sent by the calculate button:

_POST Array
(
    [wpsc_ajax_action] => update_location
    [country] => US
    [collected_data] => Array
        (
            [15] => Alaska
            [16] => Array
                (
                    [1] => 15
                )

        )

    [wpsc_update_location] => true
    [wpsc_submit_zipcode] => Calculate
)

On an install that's been upgraded (Admittedly across many different versions over time - it's a general sandbox install), the POST data sent is weird:

_POST Array
(
    [wpsc_ajax_action] => update_location
    [country] => Array
        (
            [1] => 65
        )

    [collected_data] => Array
        (
            [158] => 
            [159] => Array
                (
                    [1] => 65
                )

        )

    [wpsc_update_location] => true
    [wpsc_submit_zipcode] => Calculate
    [region] => 65
    [zipcode] => 
)

Particularly, the "country" var should be set to an ISOcode ("US"), but is actually an array containing a single ID value.

My guess that that's what is confusing the shipping module and causing it to return no rates. no idea why the POST data would be wrong though - any ideas Justin?

npdemers commented 9 years ago

Sorry, I should have said what the expected shipping rates are, per country/continent: -Canada: $0 -USA: $5 -Anywhere else: $10

And to answer your question: an initial shipping fee of $0 was expected, yes. But the issue is that it should be recalculated when the checkbox is clicked.

If you manually enter a shipping address and submit, then the shipping rate is correct when you get to PayPal.

npdemers commented 9 years ago

FYI, I've uninstalled WP e-c and reinstalled the 3.9 version. Shipping is still not recalculated.

Also, am I the only one who sees both sets of address fields as well as the Submit button disappear when the "Shipping Address same as Billing Address?" checkbox is clicked?

mihaijoldis commented 9 years ago

@npdemers i just tested http://dreamfilm.staging.wpengine.com/ I`m pretty sure the problem you have is with an outdated WP eCommerce theme file. I suspect the checkout page file in your active theme is old. Clicking the Shipping same as billing box should trigger an AJAX request which your website does not.

Go in your active theme and rename that file wpsc-shopping_cart_page.php and then flush the cache from the Presentation Page and give it another try.

npdemers commented 9 years ago

I've done so, but it's still not helping. This is the same wpsc-shopping_cart_page.php that was working fine with 3.8.12.1.

As for my other issue (all address fields disappearing) that was a theming thing, I just had to tweak the wpsc-shopping_cart_page.php a bit.

mihaijoldis commented 9 years ago

The shipping calculator is not showing at all from what i can see. Can you mail me FTP and admin logins at mihai @ instinct.co.nz

npdemers commented 9 years ago

Sorry @misulicus please don't take this the wrong way, but I don't know you and I don't think the client would approve of me giving out logins even if it's a staging site.

Incidentally, I've disabled all non-WP-e-c plugins and switched to Twenty Fourteen, but it's still not working. Clicking on the checkbox does not send any Ajax call, and the shipping address fields are not updated.

And looking at the code again, in particular at the wpsc-core/wp-e-commerce.js file, I'm more confused than ever. In 3.8.12 toggling the "Shipping address same as billing" checkbox triggers Ajax calls: in the change() event, line 158, which also calls wpsc_update_shipping_quotes(), which does another Ajax call.

In 3.9, toggling the checkbox calls wpsc_adjust_checkout_form_element_visibility(), which shows or hides shipping address fields but doesn't seem to call any Ajax.

What am I missing? Does the "Shipping address same as billing" checkbox not fire an Ajax call anymore?

JustinSainton commented 9 years ago

Hi @npdemers,

If you click the checkbox, you should see an AJAX request in your Network console (this is from Chrome) that shows the following request values:

http://cl.ly/image/0j3t1H240u23

An AJAX request is definitely being fired, can you confirm?

JustinSainton commented 9 years ago

@JeffPyeBrook ping on this :)

npdemers commented 9 years ago

There's no Ajax when I click the checkbox. :(

That's in the staging site, http://dreamfilm.staging.wpengine.com/store

The live site, which is at http://dreamfilm.ca/store and is running 3.8.12.1, does fire 2 Ajax requests (shipping_same_as_billing_update and wpsc_shipping_same_as_billing)

How are you firing wpsc_customer_updated_data?

ncklln commented 9 years ago

Hi - did you ever get to the bottom of this? I have the same issue. http://www.pussyhomeboutique.co.uk The shipping isn't added until the customer leaves the site and arrives at sagepay. Have tried with the Default Shipping Country script, but makes no difference. Once you click 'update' on the checkout page it works fine... Thanks in advance

npdemers commented 9 years ago

I have, but it's not a solution I'm happy with. It works, but basically I had to add some logic to my theme. Logic that was there in 3.8.12 but missing in 3.9.3, namely function wpsc_update_shipping_quotes() (used to be in wpsc-core/js/wp-e-commerce.js but is now in wpsc-core/js/wpsc-deprecated.js) and the jQuery fired by the "Shipping address same as billing" checkbox.

(Also I tweaked the wpsc-shopping_cart_page.php template a little to keep the Submit button from disappearing when the "Shipping address same as billing" checkbox is clicked.)

ncklln commented 9 years ago

Yep I just looked at your site and you've got the same issue as me. i only ship to one country so I want the shipping to calculate automatically on the checkout page - LIKE IT USED TO!! Don't you just hate it when people 'improve' their products and ruin them! I'm a self-taught website maker so your tweaks look a bit to complicated for me, but thanks for your help anyway. Nick