Zen Cart Logo
Forums / Addon Sideboxes / Trying to Update the PayPal Verified Sidebox

Trying to Update the PayPal Verified Sidebox

Views: 13,178

Results 1 to 15 of 15
14 Apr 2016, 5:01 PM
#1
dream9studios avatar

dream9studios

New Zenner

Join Date:
Sep 2012
Location:
Illinois
Posts:
24
Plugin Contributions:
0

Trying to Update the PayPal Verified Sidebox

I want to update the old 1.3 version sidebox with clickable PayPal Verified Logo to use work in 1.5.5 with new links and images. I've only ran into one problem so far and that's due to my apparent lack of PHP knowledge when it comes to integrating javascript. I want to change the link so it acts like modern PayPal logo buttons. I'd appreciate any and all help/advice.

Here's the code from the PayPal website that I want to use for my link:

<a href="https://www.paypal.com/webapps/mpp/paypal-popup" title="How PayPal Works" onclick="javascript:window.open('https://www.paypal.com/webapps/mpp/paypal-popup','WIPaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700'); return false;">

Here is the code from the plugin where I want to put the new link:

<!-- Begin Official PayPal Seal -->
<a target="_blank" href="https://www.paypal.com/webapps/mpp/paypal-popup">' .
zen_image(DIR_WS_TEMPLATE_IMAGES . MODULE_PAYPAL_SEAL_LOGO_IMAGE_FILENAME, MODULE_PAYPAL_SEAL_ALT_TEXT, 100, 100) .
'</a>
<!-- End Official PayPal Seal -->

I want the link to click into a popup box like it would on a normal webpage. I keep running into PHP errors when I tried coding it myself and I've broke my test shop enough times today so I'm asking for help. :) I've got everything working except the pop-up link. Thank you.

14 Apr 2016, 6:15 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Trying to Update the PayPal Verified Sidebox

Inside sideboxes, because you're sticking content into the $content variable, you need to "escape" the quotes.

Example:
for:

$content = ' your custom stuff here ';

to add stuff inside those quotes where you want to also use single-quotes (like your javascript stuff inside that paypal snippet), you need to add a \ before every single-quote you want to keep inside the outer-most single-quotes.

ie:

$content = ' when I\'ve got single quotes I\'ve gotta escape them! ';
14 Apr 2016, 8:19 PM
#3
dream9studios avatar

dream9studios

New Zenner

Join Date:
Sep 2012
Location:
Illinois
Posts:
24
Plugin Contributions:
0

Re: Trying to Update the PayPal Verified Sidebox

I think I understand what you mean. The code "works" in that is doesn't break the sidebox anymore but the javascript itself doesn't work to create a popup window. It just opens in a new tab. If I take out the _blank then it opens in the same window. Here's the full code:

  define('MODULE_PAYPAL_SEAL_LOGO_IMAGE_FILENAME', 'paypal_secured.gif');
  define('MODULE_PAYPAL_SEAL_VERIFIED_URL', 'https://www.paypal.com/webapps/mpp/paypal-popup');

  $content = '';
  $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">' . "\n";
  $content .= '<div class="wrapper">' . "\n";

  $content .=
'<center>
<!-- Begin Official PayPal Seal -->
<a target= " _blank " href= " ' .MODULE_PAYPAL_SEAL_VERIFIED_URL . ' " onclick= javascript:window.open(\'https://www.paypal.com/webapps/mpp/paypal-popup\',\'WIPaypal\',\'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700\');>' .
zen_image(DIR_WS_TEMPLATE_IMAGES . MODULE_PAYPAL_SEAL_LOGO_IMAGE_FILENAME, MODULE_PAYPAL_SEAL_ALT_TEXT, 150, 100) .
'</a>
<!-- End Official PayPal Seal -->
</center>';
  $content .= '</div>' . "\n";
  $content .= '</div>';
14 Apr 2016, 9:55 PM
#4
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Trying to Update the PayPal Verified Sidebox

it would help if you could provide a link to your site.

are you sure that your javascript is executing without errors? have you checked the console in the developers tools?

14 Apr 2016, 9:58 PM
#5
dream9studios avatar

dream9studios

New Zenner

Join Date:
Sep 2012
Location:
Illinois
Posts:
24
Plugin Contributions:
0

Re: Trying to Update the PayPal Verified Sidebox

I apologize, I thought I had posted a link to my site. I've been building this new store from scratch since late last night and trying to do too many things at once. Here is the link: http://shp.d9s.co/ The PayPal Sidebox is at the bottom of the left sidebar.

14 Apr 2016, 10:18 PM
#6
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Trying to Update the PayPal Verified Sidebox

first, i think you are missing the return false....

if you look at the source of the page (press ctrl-u), you can see that your quoting is off. i have attached a screenshot. you need to adjust the code to remove the quotes that are there.

i do not have the code worked our right this moment, but if you look at your original post as to what you want and what you are getting, you can see where the errors are.

good luck!

14 Apr 2016, 11:15 PM
#7
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Trying to Update the PayPal Verified Sidebox

I believe that you need one more file a .js file named jscript_positionedPopup.js with this as the contents

<script language="javascript">
var popupWindow = null;
function positionedPopup(url,winName,w,h,t,l,scroll){
settings =
'height='+h+',width='+w+',top='+t+',left='+l+',scrollbars='+scroll+',resizable'
popupWindow = window.open(url,winName,settings)
}
</script>

Place the file in your templates jscript folder
includes/templates/dream9shp/jscript/
and adjust your "onclick" code

onclick="positionedPopup...
15 Apr 2016, 12:04 AM
#8
dream9studios avatar

dream9studios

New Zenner

Join Date:
Sep 2012
Location:
Illinois
Posts:
24
Plugin Contributions:
0

Re: Trying to Update the PayPal Verified Sidebox

kobra:

I believe that you need one more file a .js file named jscript_positionedPopup.js with this as the contents

<script language="javascript"> var popupWindow = null; function positionedPopup(url,winName,w,h,t,l,scroll){ settings = 'height='+h+',width='+w+',top='+t+',left='+l+',scrollbars='+scroll+',resizable' popupWindow = window.open(url,winName,settings) } </script>
> Place the file in your templates jscript folder
> includes/templates/dream9shp/jscript/
> and adjust your "onclick" code
> ```
onclick="positionedPopup...

I'm getting a syntax error on this line and my brain just went blank as to how to fix it:

popupWindow = window.open(url,winName,settings)
15 Apr 2016, 12:50 AM
#9
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Trying to Update the PayPal Verified Sidebox

Opps!!!

Try this

popupWindow = window.open(url,'name',settings)
15 Apr 2016, 2:29 AM
#10
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Trying to Update the PayPal Verified Sidebox

ok, here is my take... i agree with kobra in that it will seems easier with a .js file. i would use the following:

<script type="text/javascript"><!--
function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}
//--></script>

replace my variables with whatever you want/need/ is provided at the top of your code.

then for the php part:

//replace:

  $content .=
'<center>
<!-- Begin Official PayPal Seal -->
<a target= " _blank " href= " ' .MODULE_PAYPAL_SEAL_VERIFIED_URL . ' " onclick= javascript:window.open(\'https://www.paypal.com/webapps/mpp/paypal-popup\',\'WIPaypal\',\'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700\');>' .
zen_image(DIR_WS_TEMPLATE_IMAGES . MODULE_PAYPAL_SEAL_LOGO_IMAGE_FILENAME, MODULE_PAYPAL_SEAL_ALT_TEXT, 150, 100) .
'</a>
<!-- End Official PayPal Seal -->
</center>';

//with:

$content .=
    '<center>
<!-- Begin Official PayPal Seal -->
<a target= " _blank " href= " ' .MODULE_PAYPAL_SEAL_VERIFIED_URL . ' " onclick="popupWindow(this.href); return false">' .
    zen_image(DIR_WS_TEMPLATE_IMAGES . MODULE_PAYPAL_SEAL_LOGO_IMAGE_FILENAME, MODULE_PAYPAL_SEAL_ALT_TEXT, 150, 100) .
    '</a>
<!-- End Official PayPal Seal -->
</center>';

make sure the javascript code gets loaded...

hope that helps!

good luck!

15 Apr 2016, 2:45 AM
#11
dream9studios avatar

dream9studios

New Zenner

Join Date:
Sep 2012
Location:
Illinois
Posts:
24
Plugin Contributions:
0

Re: Trying to Update the PayPal Verified Sidebox

Thank you so much for everyone's help!

It was working for a few minutes and now it's stopped which is weird as I don't know what. The popup window showed up but was only 100x100px so I tried editing the variables to make it 1060x700 but then the popup stopped working so I restored the files to where they were last working and now it's not popping up again. I think I'll stop for tonight and try again in the morning before I mess up anything else.

15 Apr 2016, 6:39 AM
#12
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Trying to Update the PayPal Verified Sidebox

carlwhat,
The javascript should match the name of the jscript file created instead of window.open

onclick= javascript:window.open
15 Apr 2016, 2:49 PM
#13
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Trying to Update the PayPal Verified Sidebox

kobra,
i'm not following you. can you explain what i'm missing here in your comment?

i'm using an example that i worked on a bit ago. if you go here:

http://lawineco.com/2005-chateau-certan-de-may-w-15561

in the middle of the page, there is a red link called Pre-Order. i make use of similar code for this pop-up.

thanks for any clarification. as i am always game to learn and appreciative of any help.

Dreams9: you are close!

i think where you have gone wrong or perhaps we have lead you astray is in the naming convention of your file:

http://shp.d9s.co/includes/templates/dream9shp/jscript/jscript_positionedPopup.js

apache thinks this file is a javascript file, but you have html tags in it. remove the script tags so that the file just contains:

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=1060,height=700,screenX=1060,screenY=700,top=150,left=150')
}

and let us know how it goes.

good luck!

15 Apr 2016, 7:39 PM
#14
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Trying to Update the PayPal Verified Sidebox

i'm not following you. can you explain what i'm missing here in your comment?
Nevermind - I must have been tired

16 Apr 2016, 1:04 AM
#15
dream9studios avatar

dream9studios

New Zenner

Join Date:
Sep 2012
Location:
Illinois
Posts:
24
Plugin Contributions:
0

Re: Trying to Update the PayPal Verified Sidebox

It works! It works!! YAY!! Thank you so very, very much! :D