jeffharrell / minicart

The minicart is a great way to improve your PayPal shopping cart integration.
MIT License
501 stars 209 forks source link

Minicart v3.0.5 Not passing weight to paypal #247

Open GriffinCreativeStudios opened 10 years ago

GriffinCreativeStudios commented 10 years ago

First let me say thank you for making this tool available under the license you do! It is obviously quite a bit of work, and please don't take this "issue" I'm having to mean I don't appreciate what you have done here!

Anyway, I'm experiencing a problem which seems to be a fairly regular issue for mini cart users, based on past issues that have been submitted to this repository.

When the default distribution of minicart is being used, the weight (as defined in an <input type="hidden name="weight" value="x" /> tag does not get sent to paypal, and the shipping calculations result in a $0.00 shipping rate.

When I do not call minicart into my page, the weight is sent to my paypal cart just fine, and upon checking out the cumulative weight of my products is used to calculate shipping.

Looking a bit deeper into minicart, it does not appear that 'weight' is even one of the settings that is preserved by minicart.

I tried simply adding "weight|" to the settings array in the b.exports function, but that did not work.

I tried rooting around in the template, and substituting weight for shipping and shipping2, which do work, but to no avail. I went as deep as I am able to, used google extensively, and tried to fix the issue myself before posting on here.

Does anyone have any idea how to rectify this, or what I'm doing wrong?

I would very much appreciate any help anyone can give.

Thanks for your hard work on this otherwise wonderful project.

EDIT: Here is a test page with minicart - http://www.griffincreativestudios.com/minicartbigtrouble/withminicart.html

And here is a test page, with the same HTML, without minicart - http://www.griffincreativestudios.com/minicartbigtrouble/withoutminicart.html

Finally, this is the exact source I amusing for minicart - http://cdnjs.cloudflare.com/ajax/libs/minicart/3.0.5/minicart.min.js

Also, here is a post I made about this issue on www.reddit.com/r/webdev - http://www.reddit.com/r/webdev/comments/2f3oxl/im_having_trouble_passing_weight_variables_to/

It contains a more detailed account of my attempts to resolve this issue (as I am familiar with their markup).

PARTIAL SOLUTION: I have gotten weights to pass through to paypal, but somehow they may not be correct.

What I've done so far, is I've included a function which rounds numbers to 2 decimals (because for some strange reason multiplication of .31*2 was resulting in .619999999999909 instead of .62

This is that function:

function precise_round(num,decimals) { return Math.round(num * Math.pow(10, decimals)) / Math.pow(10, decimals); }

Then I added an input into a custom template which takes the "weight" variable and applies its value to weight_X, where x represents its item number in the cart.

<input type="hidden" name="weight_<%= idx %>" value="<%= precise_round(items[i].get("weight")*items[i].get("quantity"),2) %>" />

The problem I'm having now is that the numbers I know are leaving minicart (I'm catching them by echoing $_POST('weight_1') and $_POST('weight_2') in a PHP handler as the action) aren't getting to paypal correctly.

Paypal is calculating these numbers as being higher than they really are, because the shipping costs that papal is calculating based on my Shipping Rate Settings are being provided by higher tiers than they should be (i.e. if I have a rule that weights between .01lb and .64lb should cost $3.50, and weights between .65lb and 2.8lb should cost $6, a weight_1 of.31 and a weight_2 of .28, which equals .59lb is costing $6.00 to ship.

fabriziotappero commented 9 years ago

Hello, I am very interested about this issue. I am currently using minicart and I have different products and I need shipping to be calculated at the real end of the order. Would be great to have an answer to this question. Regards

fabriziotappero commented 9 years ago

would it be possible to know if there is a way to calculate the final shipping cost based on the weight of each single bought item. It seems to me a very basic feature of minicart that I am surprised I and few others have this problem.

Thanks a lot for this great software.

fabriziotappero commented 9 years ago

Here is an implementation of PayPal Minicart were shipping costs are based on item weight. Shipping calculation happens instantly and is shown as an item in the main Cart.

Done in this way, there is no need for PayPal weight calculation nor any PayPal business account.

Any feedback is welcome.

http://fabriziotappero.github.io/minicart-plus/index.html

adpinc commented 8 years ago

Has this been solved yet? As of today, I still cannot get the weight to pass to PayPal. I've tried a number of things without success.

fabriziotappero commented 8 years ago

This http://fabriziotappero.github.io/minicart-plus/demo.html

Works perfectly. Doesn't it?

Cheers Fabrizio

adpinc commented 8 years ago

Your solution assumes that the shipping is always domestic. How do you determine whether or not the buyer is domestic or international? Are you checking that on the client side and then passing it over to PayPal? If I knew all of my shipments were domestic, I could do this.

Any thoughts are appreciated.

From: Fabrizio [mailto:notifications@github.com] Sent: Saturday, November 07, 2015 8:44 PM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

This http://fabriziotappero.github.io/minicart-plus/demo.html

Works perfectly. Doesn't it?

Cheers Fabrizio

— Reply to this email directly or view it on GitHub https://github.com/jeffharrell/minicart/issues/247#issuecomment-154769746 . https://github.com/notifications/beacon/AFehTthhvcWQiZzaWYf6xXQqZXKubw6Sks5pDqBrgaJpZM4Cc9h7.gif

fabriziotappero commented 8 years ago

Hi. You have few options here: 1 you ask the buyer for its address and you determine the price and you pass everything to paypal 2 you ask the buyer for its state or continent via a drop down menu. 3 you do not ask and use an averaged shipping price 4 you use a more complicate paypal js tool that you buy somewhere 5 you guess its location via some js tool.

I would go for the 5 or 3.

Cheers Fabrizio

On Nov 8, 2015 3:23 AM, "adpinc" notifications@github.com wrote:

Your solution assumes that the shipping is always domestic. How do you determine whether or not the buyer is domestic or international? Are you checking that on the client side and then passing it over to PayPal? If I knew all of my shipments were domestic, I could do this.

Any thoughts are appreciated.

From: Fabrizio [mailto:notifications@github.com] Sent: Saturday, November 07, 2015 8:44 PM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

This http://fabriziotappero.github.io/minicart-plus/demo.html

Works perfectly. Doesn't it?

Cheers Fabrizio

— Reply to this email directly or view it on GitHub < https://github.com/jeffharrell/minicart/issues/247#issuecomment-154769746> . < https://github.com/notifications/beacon/AFehTthhvcWQiZzaWYf6xXQqZXKubw6Sks5pDqBrgaJpZM4Cc9h7.gif>

— Reply to this email directly or view it on GitHub https://github.com/jeffharrell/minicart/issues/247#issuecomment-154771031 .

adpinc commented 8 years ago

Hi Fabrizio,

Thanks for the tips. I decided to abandon the minicart and simply wrote my own cart that uploads to PayPal perfectly. Now its seamless with my website, though not on line yet. The error with the “weight” passthru actually motivated me to do this anyway.

I can send you a link to my site if you like, once do my final release.

Allan

From: Fabrizio [mailto:notifications@github.com] Sent: Sunday, November 08, 2015 11:42 AM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

Hi. You have few options here: 1 you ask the buyer for its address and you determine the price and you pass everything to paypal 2 you ask the buyer for its state or continent via a drop down menu. 3 you do not ask and use an averaged shipping price 4 you use a more complicate paypal js tool that you buy somewhere 5 you guess its location via some js tool.

I would go for the 5 or 3.

Cheers Fabrizio

On Nov 8, 2015 3:23 AM, "adpinc" notifications@github.com wrote:

Your solution assumes that the shipping is always domestic. How do you determine whether or not the buyer is domestic or international? Are you checking that on the client side and then passing it over to PayPal? If I knew all of my shipments were domestic, I could do this.

Any thoughts are appreciated.

From: Fabrizio [mailto:notifications@github.com] Sent: Saturday, November 07, 2015 8:44 PM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

This http://fabriziotappero.github.io/minicart-plus/demo.html

Works perfectly. Doesn't it?

Cheers Fabrizio

— Reply to this email directly or view it on GitHub < https://github.com/jeffharrell/minicart/issues/247#issuecomment-154769746> . < https://github.com/notifications/beacon/AFehTthhvcWQiZzaWYf6xXQqZXKubw6Sks5pDqBrgaJpZM4Cc9h7.gif>

— Reply to this email directly or view it on GitHub https://github.com/jeffharrell/minicart/issues/247#issuecomment-154771031 .

— Reply to this email directly or view it on GitHub https://github.com/jeffharrell/minicart/issues/247#issuecomment-154840237 . https://github.com/notifications/beacon/AFehTsqu4DQ_h36kqA9-qaz2tMPJvmAAks5pD3LxgaJpZM4Cc9h7.gif

fabriziotappero commented 8 years ago

Hi Allan, Sure, I would be very happy to take a look at the code. To directly pass the weight to PayPal, do you need any special business PayPal account? Cheers Fabrizio On Nov 8, 2015 5:46 PM, "adpinc" notifications@github.com wrote:

Hi Fabrizio,

Thanks for the tips. I decided to abandon the minicart and simply wrote my own cart that uploads to PayPal perfectly. Now its seamless with my website, though not on line yet. The error with the “weight” passthru actually motivated me to do this anyway.

I can send you a link to my site if you like, once do my final release.

Allan

From: Fabrizio [mailto:notifications@github.com] Sent: Sunday, November 08, 2015 11:42 AM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

Hi. You have few options here: 1 you ask the buyer for its address and you determine the price and you pass everything to paypal 2 you ask the buyer for its state or continent via a drop down menu. 3 you do not ask and use an averaged shipping price 4 you use a more complicate paypal js tool that you buy somewhere 5 you guess its location via some js tool.

I would go for the 5 or 3.

Cheers Fabrizio

On Nov 8, 2015 3:23 AM, "adpinc" notifications@github.com wrote:

Your solution assumes that the shipping is always domestic. How do you determine whether or not the buyer is domestic or international? Are you checking that on the client side and then passing it over to PayPal? If I knew all of my shipments were domestic, I could do this.

Any thoughts are appreciated.

From: Fabrizio [mailto:notifications@github.com] Sent: Saturday, November 07, 2015 8:44 PM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

This http://fabriziotappero.github.io/minicart-plus/demo.html

Works perfectly. Doesn't it?

Cheers Fabrizio

— Reply to this email directly or view it on GitHub <

https://github.com/jeffharrell/minicart/issues/247#issuecomment-154769746> . <

https://github.com/notifications/beacon/AFehTthhvcWQiZzaWYf6xXQqZXKubw6Sks5pDqBrgaJpZM4Cc9h7.gif

— Reply to this email directly or view it on GitHub < https://github.com/jeffharrell/minicart/issues/247#issuecomment-154771031> .

— Reply to this email directly or view it on GitHub < https://github.com/jeffharrell/minicart/issues/247#issuecomment-154840237> . < https://github.com/notifications/beacon/AFehTsqu4DQ_h36kqA9-qaz2tMPJvmAAks5pD3LxgaJpZM4Cc9h7.gif>

— Reply to this email directly or view it on GitHub https://github.com/jeffharrell/minicart/issues/247#issuecomment-154840435 .

adpinc commented 8 years ago

You need to have a PayPal Merchant account in order to process the transactions. Once you have that, you have access to all their query string variables.

From: Fabrizio [mailto:notifications@github.com] Sent: Sunday, November 08, 2015 5:14 PM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

Hi Allan, Sure, I would be very happy to take a look at the code. To directly pass the weight to PayPal, do you need any special business PayPal account? Cheers Fabrizio On Nov 8, 2015 5:46 PM, "adpinc" notifications@github.com wrote:

Hi Fabrizio,

Thanks for the tips. I decided to abandon the minicart and simply wrote my own cart that uploads to PayPal perfectly. Now its seamless with my website, though not on line yet. The error with the “weight” passthru actually motivated me to do this anyway.

I can send you a link to my site if you like, once do my final release.

Allan

From: Fabrizio [mailto:notifications@github.com] Sent: Sunday, November 08, 2015 11:42 AM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

Hi. You have few options here: 1 you ask the buyer for its address and you determine the price and you pass everything to paypal 2 you ask the buyer for its state or continent via a drop down menu. 3 you do not ask and use an averaged shipping price 4 you use a more complicate paypal js tool that you buy somewhere 5 you guess its location via some js tool.

I would go for the 5 or 3.

Cheers Fabrizio

On Nov 8, 2015 3:23 AM, "adpinc" notifications@github.com wrote:

Your solution assumes that the shipping is always domestic. How do you determine whether or not the buyer is domestic or international? Are you checking that on the client side and then passing it over to PayPal? If I knew all of my shipments were domestic, I could do this.

Any thoughts are appreciated.

From: Fabrizio [mailto:notifications@github.com] Sent: Saturday, November 07, 2015 8:44 PM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

This http://fabriziotappero.github.io/minicart-plus/demo.html

Works perfectly. Doesn't it?

Cheers Fabrizio

— Reply to this email directly or view it on GitHub <

https://github.com/jeffharrell/minicart/issues/247#issuecomment-154769746> . <

https://github.com/notifications/beacon/AFehTthhvcWQiZzaWYf6xXQqZXKubw6Sks5pDqBrgaJpZM4Cc9h7.gif

— Reply to this email directly or view it on GitHub < https://github.com/jeffharrell/minicart/issues/247#issuecomment-154771031> .

— Reply to this email directly or view it on GitHub < https://github.com/jeffharrell/minicart/issues/247#issuecomment-154840237> . < https://github.com/notifications/beacon/AFehTsqu4DQ_h36kqA9-qaz2tMPJvmAAks5pD3LxgaJpZM4Cc9h7.gif>

— Reply to this email directly or view it on GitHub https://github.com/jeffharrell/minicart/issues/247#issuecomment-154840435 .

— Reply to this email directly or view it on GitHub https://github.com/jeffharrell/minicart/issues/247#issuecomment-154879858 . https://github.com/notifications/beacon/AFehTmSMK1NNLto9NNlKyobXZwVJe6l4ks5pD8CwgaJpZM4Cc9h7.gif

fabriziotappero commented 8 years ago

I see, well in that case I might prefer an alternative solution that actually works with the standard PayPal account.

Cheers Fabrizio

Fabrizio Tappero

On Sun, Nov 8, 2015 at 11:18 PM, adpinc notifications@github.com wrote:

You need to have a PayPal Merchant account in order to process the transactions. Once you have that, you have access to all their query string variables.

From: Fabrizio [mailto:notifications@github.com] Sent: Sunday, November 08, 2015 5:14 PM

To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

Hi Allan, Sure, I would be very happy to take a look at the code. To directly pass the weight to PayPal, do you need any special business PayPal account? Cheers Fabrizio On Nov 8, 2015 5:46 PM, "adpinc" notifications@github.com wrote:

Hi Fabrizio,

Thanks for the tips. I decided to abandon the minicart and simply wrote my own cart that uploads to PayPal perfectly. Now its seamless with my website, though not on line yet. The error with the “weight” passthru actually motivated me to do this anyway.

I can send you a link to my site if you like, once do my final release.

Allan

From: Fabrizio [mailto:notifications@github.com] Sent: Sunday, November 08, 2015 11:42 AM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

Hi. You have few options here: 1 you ask the buyer for its address and you determine the price and you pass everything to paypal 2 you ask the buyer for its state or continent via a drop down menu. 3 you do not ask and use an averaged shipping price 4 you use a more complicate paypal js tool that you buy somewhere 5 you guess its location via some js tool.

I would go for the 5 or 3.

Cheers Fabrizio

On Nov 8, 2015 3:23 AM, "adpinc" notifications@github.com wrote:

Your solution assumes that the shipping is always domestic. How do you determine whether or not the buyer is domestic or international? Are you checking that on the client side and then passing it over to PayPal? If I knew all of my shipments were domestic, I could do this.

Any thoughts are appreciated.

From: Fabrizio [mailto:notifications@github.com] Sent: Saturday, November 07, 2015 8:44 PM To: jeffharrell/minicart Cc: adpinc Subject: Re: [minicart] Minicart v3.0.5 Not passing weight to paypal (#247)

This http://fabriziotappero.github.io/minicart-plus/demo.html

Works perfectly. Doesn't it?

Cheers Fabrizio

— Reply to this email directly or view it on GitHub <

https://github.com/jeffharrell/minicart/issues/247#issuecomment-154769746>

. <

https://github.com/notifications/beacon/AFehTthhvcWQiZzaWYf6xXQqZXKubw6Sks5pDqBrgaJpZM4Cc9h7.gif

— Reply to this email directly or view it on GitHub <

https://github.com/jeffharrell/minicart/issues/247#issuecomment-154771031>

.

— Reply to this email directly or view it on GitHub <

https://github.com/jeffharrell/minicart/issues/247#issuecomment-154840237> . <

https://github.com/notifications/beacon/AFehTsqu4DQ_h36kqA9-qaz2tMPJvmAAks5pD3LxgaJpZM4Cc9h7.gif

— Reply to this email directly or view it on GitHub < https://github.com/jeffharrell/minicart/issues/247#issuecomment-154840435> .

— Reply to this email directly or view it on GitHub < https://github.com/jeffharrell/minicart/issues/247#issuecomment-154879858> . < https://github.com/notifications/beacon/AFehTmSMK1NNLto9NNlKyobXZwVJe6l4ks5pD8CwgaJpZM4Cc9h7.gif>

— Reply to this email directly or view it on GitHub https://github.com/jeffharrell/minicart/issues/247#issuecomment-154881456 .

Sarke commented 7 years ago

https://github.com/jeffharrell/minicart/issues/284#issuecomment-292380742