Help with some javascript

  • 1
  • Question
  • Updated 7 years ago
  • Answered
I've found a cool paypal mini cart for those of us who haven't got a paypal premium account, instead of being directed away to another page the checkout pops up on the same screen until you need to pay.
My problem is I can't get it to work, the instructions are not absolutely clear and an email to their support resulted in a link to the instructions page.
Please could someone with a bit of javascript knowledge take a look and explain in simple terms what I have to do.
The cart is here

https://minicart.paypal-labs.com/#tab...

Thanks
Photo of David

David

  • 465 Posts
  • 94 Reply Likes

Posted 7 years ago

  • 1
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
Hi David,

It looks like you need to upload files to do this. I have done this already, so I have a code for you that should work.

Just drag over an HTML widget and paste this into it at the top of your page:


<script src="http://tester3.yolasite.com/resources/javascript/minicart.js" type="text/javascript"></script>
<script type="text/javascript">
PAYPAL.apps.MiniCart.render();
</script>



That's it. That should make it work.

I hope this helps!

Nathan
Photo of David

David

  • 465 Posts
  • 94 Reply Likes
Hi Nathan
Thanks for the quick reply, I've tried your code and it still redirects to a separate paypal checkout page, if you could take a look its on this page

http://www.leathersolutions.org/test.php

Thanks
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
Hi David,

Could you try putting the HTML widget before everything else? (at the very top of your page) I looked in your source code and it seems to be after the add to cart thing that is opening a new page which may be causing that to happen.

Please let us know if this works.

Nathan
Photo of David

David

  • 465 Posts
  • 94 Reply Likes
Hello Nathan
I've placed the widget above the add to button and its still redirecting to the other page, any further thoughts would be appreciated.
Photo of diane

diane

  • 1238 Posts
  • 121 Reply Likes
Hi, David,

Pardon me for jumping in here. It looks like you're calling the function twice and the second time is trying to run a tar.gz instead of a .js file. This may be the problem.

Here's the code I'm seeing:



<script src="resources/jeffharrell-MiniCart-2.0.5-13-g0ed3560.tar.gz" type="text/javascript"></script> <script type="text/javascript"> PAYPAL.apps.MiniCart.render(); </script>



Delete the widget with this code and the one above it should work (hopefully).
Photo of David

David

  • 465 Posts
  • 94 Reply Likes
Thanks Diane that was one of my earlier attempts which I'd forgotten to delete, unfortunately its still directing away. By using a widget is the code in the right place as per their tutorial?

'Next, include the following bit of JavaScript on your page before the closing <!--</body>--> tag'

Thanks Diane and Nathan for your help, I would really like to get this to work.
Photo of Nazlie

Nazlie

  • 1721 Posts
  • 51 Reply Likes
Hi David

If you have added it in the content area of the page, it should work correctly as that is before the close <!--</body>--> tag.
Photo of diane

diane

  • 1238 Posts
  • 121 Reply Likes
Hi, David,

In looking through the PayPal page, it says that hosted and encrypted buttons will redirect to the PayPal page. See the FAQ tab on the mini-cart page. I think this may be the cause of the problem.
Photo of David

David

  • 465 Posts
  • 94 Reply Likes
Hello Diane
Yes I looked at that and it could be that the "remove code protection" check box is ticked causing the problem, I haven't been able to check as I don't know where it is!
After several emails, not all polite I've finally got someone from paypal on the case, I guess you get used to the good service on this forum that you notice other company's failings easier.
If I can find a solution I'll post back for your information, thanks for the help.

Nathan
I would like to host the file myself, please could you explain exactly the file I have to download as there is several to choose from, what bits of it or all I have to upload to file manager and the file name for the path in the JavaScript file, apologies for being fussy but JavaScript is quite new to me, thanks also.
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
Hi David,

Did you try putting the Paypal code in the "footer" area of the site tracking code? That would put it right before the closing </body> tag. The site tracking code dialog is located in Site > Site Settings > Site Tracking Code (on the last row)

Regarding hosting the file yourself, just copy the whole code from here, paste it into Notepad or another text editor, (not a Word Processor) and save it as "minicart.js" Make sure for the file type it is set as "All Files" and not ".txt" when you save it.

Once you do this, then you can upload it to the file manager and link to it in the code like this:


<script src="resources/minicart.js" type="text/javascript"></script>
<script type="text/javascript">
PAYPAL.apps.MiniCart.render();
</script>



Hope this helps.

Nathan
Photo of David

David

  • 465 Posts
  • 94 Reply Likes
Hi Nathan
Thanks for the info, I've followed your instructions but for some reason the file isn't uploading to the file manager, the progress bar will show and work as normal but the files not there, I assume .js files can be uploaded? or maybe a problem with the file manager itself?
I will carry on with the file you are hosting until I can fix this.
Thanks
Photo of David

David

  • 465 Posts
  • 94 Reply Likes
Hi Nathan
I've just spotted on another thread that .js files are not allowed to be uploaded to file manager as they can apparently be used maliciously. How are you hosting the file?
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
Hi David,

If you have Yola Silver, you will be able to upload JS files. If you don't have Yola Silver, unfortunately you wont be able to upload it but you could host it on www.yourjavascript.com, a free JavaScript file hosting site.

I'm able to host it because I have Yola Silver.

Nathan
Photo of David

David

  • 465 Posts
  • 94 Reply Likes
Hi Nathan
Could I allow you to continue hosting the file for me, my only reason I wanted to host it myself was in case you forgot what it was being used for and accidentally deleted it, I've done it myself in file manager.
Thanks for your help with this

Hi Yola
I don't really understand why Yola silver accounts can host .js files and free accounts can't, see thread below

http://forum.yola.com/yola/topics/wha...

Is it not the case that if a .js file can be used maliciously its irrelevant what type of account you hold. Please clarify.
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
Hi David,

Yes, I can continue to host the file for you. I put your file in a folder that I never use (unless I'm hosting someone else's file, I will go into it to upload) and I don't use the test site regularly, so it wont get deleted. :)

Regarding the .js files only on Silver, the reason behind this is because of security issues. They can't allow free accounts to upload JS files for a secuirty reason. (I heard that from an employee about a year ago before I had Silver) CSS files can be uploaded, though.

Kind regards,
Nathan
Photo of David

David

  • 465 Posts
  • 94 Reply Likes
OK Nathan thank you, regarding the .js files that is a very strange reason they gave you, are they saying silver account holders are more trustworthy then free, if so I'm sure a lot of people would beg to differ.
Photo of Emmy

Emmy

  • 5892 Posts
  • 299 Reply Likes
Hi David,
It's a good question you pose. These types of files could be used maliciously, and for a long time no one was able to upload them. We then made a decision that we would allow it as part of the Silver package because there had been many requests for this very type of file upload. It was a business decision to make it part of the package in terms of an added functionality to Silver, it did not have to do with who we trust in terms of account holders. Hope that clarifies.

Kind Regards,
Emmy
Customer Support Team Leader